Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-05-01 05:25:51

From: "Gennadiy Rozental" <rogeeff_at_[hidden]>
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> news:00f801c1f068$0c7fc650$1d00a8c0_at_pdimov2...
> >
> > X is defined in X.hpp, along with the associated traits specializations.
> The
> > problem, with a smart_ptr that uses the type of its template parameter
> > somehow alter its type (via traits, sizeof(expression-involving-X), or
> some
> > other mechanism), is that a.cpp sees a different smart_ptr<X>. So
> an
> > ODR violation.
> >
> > Note that shared_ptr doesn't have this problem.
> >
> And how shared_ptr will automatically switch between
> counting? I asking cause it was one of the reason we started to talk about
> traits.

shared_ptr uses "runtime policies." In

shared_ptr<T> pt(new U);

it is the type of U that determines its behavior, not T. (Latest CVS

Or you could hide a statically allocated object behind a shared_ptr:

U u;

void noop(U *) {}

shared_ptr<T> pt2(&u, noop);

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