PacktPublishing / Template-Metaprogramming-with-CPP

Template Metaprogramming with C++, published by Packt
MIT License
90 stars 27 forks source link

Update tail_ correctly in circular_buffer::push_back #2

Open yukula opened 1 year ago

yukula commented 1 year ago

pushback adds element out of bound for a circular buffer [ _ 3 ] when head and tail poits to '3' How to reproduce: circular_buffer<int, 3> cb {{1,2,3}}; assert(cb.pop_front() == 1); assert(cb.pop_front() == 2); cb.pushback(4); assert(cb[0] == 3); assert(cb[1] == 4); // <<- '4' pushes to tail=3

This commit updates tail_ according to circular buffer expectations