Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-08-30 11:42:03


David Abrahams wrote:

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

>
>
>>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?
>
>
If I understand you, then this factory function creates and returns an
instance of placed_ptr<T>
by doing the allocation for T (and the refcount), calling the
appropriate T CTOR, and then
returning the placed_ptr<T>. If so, then it suffers the same
disadvantage which Philippe
objected to earlier, i.e. it would require duplicating the T CTOR
interface in the factor method.

However, despite Philippe's objection, I'm still in favor of this
approach since it's harder
for the programmer to go wrong. I mentioned this earlier:
  http://aspn.activestate.com/ASPN/Mail/Message/boost/131060
but there's obviously different views on how idiot-proof the code should
be. I also made
the same point about shared_ptr, but Peter had some objections to that
too. I can't remember
the details.

>
>


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