On 02/09/2016 12:08 PM, Peter Dimov wrote:
Phil Bouchard wrote:
I added the new repository with the right folder structure: https://github.com/philippeb8/block_ptr
Here's one vector example that shows what I had in mind:
#include
#include <vector> #include <iostream> struct X { static int instances;
std::vector< boost::block_ptr<X> > v_;
X() { ++instances; std::cout << "X(" << this << ")::X()\n";
v_.reserve( 4 ); }
~X() { std::cout << "X(" << this << ")::~X()\n"; --instances; } };
int X::instances = 0;
int main() { boost::block_ptr<X> p = boost::make_block<X>();
p->v_.push_back( p );
std::cout << "--\n";
p.reset();
std::cout << "--\n"; }
It doesn't seem to release the cycle.
Like I was saying in a PM, containers should use block_allocator<>: https://github.com/philippeb8/block_ptr/blob/master/example/block_ptr_test3.... It works well but Peter discovered a deadlock in reset() so perhaps it's a simple fix.