Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-08-30 08:54:09

From: "Larry Evans" <jcampbell3_at_[hidden]>

> Greg Colvin wrote:
> >At 11:31 AM 8/29/2002, Philippe A. Bouchard wrote:
> >
> >
> [snip]
> >>
> >>
> >My guess is that placement new is necessary so that you
> >can capture the address of the shared object, yes?
> >
> >
> >
> It's only purpose, I believe, is to avoid two allocations instead of
> one. In other words, instead of a detached reference count, as
> with shared_ptr, the reference count is allocated in the same
> block of memory as the object. You could try allocating like this:
> new rc_T<T>
> where:
> template<typename T>struct rc_T: ptr_header, T{...};
> however, this would require duplicating the T CTOR arguments in
> specializations of rc_T<T> CTORS and just forwarding them to T. However,
> in an earlier post, Phillipe said this would require too many
> specializations.

Isn't it time, finally, to stick the allocation inside a factory function
for the outer shared pointer object so that the user never has to touch it?

           David Abrahams * Boost Consulting
dave_at_[hidden] *

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