Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2006-03-29 18:02:15


David Abrahams wrote:
> Thorsten Ottosen <thorsten.ottosen_at_[hidden]> writes:
>
>> It is better that new_<T>(...) produces an unspecified type
>> that has a templated conversion operator, eg.:
>>
>> template< class T >
>> struct new_return
>> {
>> std::auto_ptr<T> new_;
>>
>> new_return( T* new_ ) : new_(new_)
>> { }
>>
>> template< class SP >
>> operator SP() const
>> {
>> return SP( new_.release() );
>> }
>>
>> operator std::auto_ptr<T>() const
>> {
>> return new_;
>> }
>> };
>>
>> Or something
>
> I started down that road, but unfortunately, there's nothing to keep
> the operator SP conversion from converting to raw pointers. ;-)
>
> I don't see why Peter is the only one who seems to be responding to
> the auto_ptr rvalue implicit conversion technique. It just works.
>
Indeed.

I agree is better than my initial proposal, and better than the parametrized
conversion op, for the reason you just gave.

Fernando Cacciola


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