#include #include int allocations = 0; struct AllocCountingObj { AllocCountingObj() { ++allocations; } AllocCountingObj(const AllocCountingObj&) { // still increment on copy-construct ++allocations; } ~AllocCountingObj() { --allocations; } }; #define println(a) std::cout << a << std::endl int main() { { const unsigned capacity = 10; boost::circular_buffer buffer; buffer.set_capacity(capacity); for (unsigned i = 1; i <= capacity * 2; ++i) { buffer.push_back(AllocCountingObj()); println("After " << i << " push_backs: " << allocations); } } println("After dtor: " << allocations); }