#include #include #include using std::cout; using std::endl; using std::distance; using boost::circular_buffer; class BufferHolder { public : typedef int data_type; private: circular_buffer data; circular_buffer::const_iterator my_end; public: BufferHolder() : data(4), my_end(data.begin()) { } void push(const data_type & value) { cout << "Current size of member circ. buffer: " << data.size() << endl; cout << "Current reserve of member circ. buffer: " << data.reserve() << endl; cout << "Pushing into circ. buffer" << endl; data.push_front(value); circular_buffer::const_iterator it = data.begin(); int amount = 25; for (int i=0; (it != my_end) && (it!=data.end()) && (amount>0) && (i::const_iterator>( data.begin(), my_end) << endl; cout << "Distance from my_end to end: " << distance::const_iterator>( my_end, data.end()) << endl; } }; int main() { BufferHolder my_buffer; for (int i=0; i<20; ++i) { cout << "=============" << endl; int datum = 5+(5*(i%2)); cout << "Pushing into my buffer: " << datum << endl; my_buffer.push(datum); } }