If you enforce that the buffer size is a power of 2 you just use a mask to do the
if (next_head == buffer.size())
next_head = 0;
partIndeed that's true. That extra constraint enables further optimization
It's mentioned in the post, but worth reiterating!
This was, in fact, mentioned in the article.
If it's a power of two, you don't need the branch at all. Let the unsigned index wrap.