我喜歡Boost Templated Circular Buffer Container,但如何獲得100%的填充?Boost循環緩衝區,如何在填充時調用某些函數?
#include <boost/circular_buffer.hpp>
int main() {
// Create a circular buffer with a capacity for 3 integers.
boost::circular_buffer<int> cb(3);
// Insert some elements into the buffer.
cb.push_back(1);
cb.push_back(2);
cb.push_back(3);
// Here I want some function to be called (for example one that would cout all buffer contents)
int a = cb[0]; // a == 1
int b = cb[1]; // b == 2
int c = cb[2]; // c == 3
return 0;
}
那麼如何來聽這樣的事件在boost::circular_buffer
和例如COUT所有緩衝區的內容?