Vladimir Grigoriev wrote:
The question arised when I tried to trap paths how auto_ptr performs
assignments and creating objects by copy.
Returning an auto_ptr<T> from a function works by bridging the
non-const "copy constructor" with another type. IIRC, the type is called
auto_ptr_ref<T> or auto_ptr<T>::ref. Anyway, what you need is an
additional
constructor taking such a type and an implicit conversion to such a type.
Note that the conversion operator may be a non-const member and that it
can
still be invoked on a temporary.
See also[1] for a template type that adapts the auto_ptr principle to
other
handle types than just pointers. Maybe that code is a bit more readable
than the average C++ stdlib implementation.
Uli
[1] http://lists.boost.org/Archives/boost/2007/11/130127.php
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Geschaftsfuhrer: Thorsten Focking, Amtsgericht Hamburg HR B62 932