Is it mandatory to store std::shared_ptr‘s in boost::circular_buffer ? If I’ve a boost::circular_buffer<T*> does the circular queue deletes the element that is automatically popped by itself after n+1th insertion ?
If not then how would I delete the popped elements and manage memory leaks ?
Of course it’s not mandatory to store
shared_ptrs, you can store lots of different types, e.g. something as simple asintIf you store pointers the container doesn’t know they point to objects on the heap, so it doesn’t delete them when overwriting existing elements with new elements, it can’t know that it would be safe to delete a pointer. The pointer is just overwritten with a new value. If that was the last pointer to an object on the heap you have a memory leak. This is pretty clearly documented less than a quarter of the way down the page. Maybe you should read the documentation.
If you store pointers to heap objects and you have no other way to manage them then yes, storing
shared_ptr<T>is sensible (but not mandatory).