
David Abrahams <dave@boost-consulting.com> writes:
Ulrich Eckhardt <doomster@knuut.de> writes:
On Wednesday 29 March 2006 08:05, Václav Veselý wrote:
I'm confused with syntax. new_<T> always creates auto_ptr<T>. How can I create for example shared_ptr<T>?
You probably can't, but: - std::auto_ptr is much less resource intensive (shared_ptr requires an additionally, dynamically-allocated structure to hold some internals) - you don't need to, as auto_ptr converts to shared_ptr, there is a special ctor taking an auto_ptr
Unfortunately for this particular facility, the converting constructor is explicit, so you can't do
f(new_<T>(a, b, c))
if f takes a shared_ptr<T>.
I just realized we could probably fix this by removing an "explicit" from the ctor that accepts an rvalue auto_ptr. What about that, Peter? This seems like a poster child for rvalue distinction! -- Dave Abrahams Boost Consulting www.boost-consulting.com