Boost logo

Boost :

Subject: Re: [boost] [block_ptr] Request for a review manager
From: Peter Dimov (lists_at_[hidden])
Date: 2016-02-09 12:08:22


> 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 <boost/block_ptr.hpp>
#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.

Other, more convoluted, examples can also be constructed, where the inner
pointer is inside a std::function member of X storing a lambda/std::bind
capturing p.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk