From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-08-29 14:24:51


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.