Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-03-29 17:06:11


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.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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