[C++-sig] Re: Allocating objects on the heap by default.
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Tue Jul 8 21:38:57 CEST 2003
>>>>> "DA" == David Abrahams <dave at boost-consulting.com> writes:
>> How about holder(A, 'std::auto_ptr'), holder(A,
>> 'boost::shared_ptr'), holder(A, 'user::smart_ptr').
DA> I dislike that because it assumes too much about the way to
DA> spell the smart pointer type: it would have to be of the form
DA> 'pointer_name<PointeeName>', which rules out,
DA> e.g. 'pointer_name<PointeeName, myAllocator>'.
[snip]
>> Internally the HeldType will add the right template parameter?
>> But what if the smart pointer is not a templated class?
DA> That's why I was suggesting
DA> holder(class_ID, unary_callable)
DA> The callable object is free to form the string any way it
DA> likes.
>> In that case we'd need to use something like this:
>>
>> holder(A, 'std::auto_ptr< %s >'), holder(A, 'user::smart_ptr').
DA> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DA> I don't understand what this part is illustrating.
It is illustrating a user namespace with a smart_ptr class that is not
templated. It does not matter.
I don't see the point of the callable function. It only seems to
complicate the interface. When writing Pyste files the user *will*
know the name of the class and will know what smart pointer he/she
wants to use. In that case I see nothing wrong with the user
specifying the entire HeldType i.e. holder('std::auto_ptr<A>') or
holder('pointer_name<PointeeName, myAllocator>') or whatever they
choose. The callable function simply adds another unnecessary layer to
this and ends up doing the same thing by generating a string that
specifies the smart pointer.
cheers,
prabhu
More information about the Cplusplus-sig
mailing list