I am trying to figure out how to use the following constructor for boost::circular_buffer:
circular_buffer(capacity_type buffer_capacity, size_type n, const_reference item, const allocator_type& alloc = allocator_type());
I have a custom class:
template<class T> class Custom
{
public:
Custom() :
time(0.0)
{}
double time;
T data_;
};
With my circular buffer defined using the constructor taking in just a capacity:
boost::circular_buffer<Custom<T>> buffer(10);
I have not worked much with allocators, and I want to initialize my buffer with default/empty/zero values at construction, and it seems that the constructor mentioned above is the way to go about it using boost::circular_buffer, however I am not exactly sure how to with boost constructor. If it were an ordinary vector I assume I can do the following:
int num_elements = 10;
Custom<T> custom;
std::vector<Custom<T>> buffer(10, custom);
I could not really find any examples on this specifically, so any help or guidance is appreciated.