Boost logo

Boost :

Subject: Re: [boost] [shifted_ptr] Documentation
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-04-09 15:55:42

Phil Bouchard wrote:

"If it is found to be living on the heap then a more complicated mechanism
is involved to track the last memory block that was allocated in the same
thread, find its address and stack up the set it will be part of until the
first shifted_ptr<T> found on the stack is or data segment is initialized,
where the new set counter will be shared with all of the newly allocated
blocks of memory referencing each other."

This doesn't seem very robust. If you have

struct X
    std::vector< shifted_ptr<A> > v_;

struct Y
    shifted_ptr<A> p_;

and then do something like

X * px = new X; // heap allocation #1
px->v_.reserve( 5 ); // heap allocation #2
Y * py = new Y; // heap allocation #3
py->p_.reset( new A ); // heap allocation #4
px->v_.push_back( py->p_ ); // no heap allocation

I see no way for the last shifted_ptr instance (px->v_[0]) to be associated
with heap allocation #1 or #2, where it belongs.

Boost list run by bdawes at, gregod at, cpdaniel at, john at