Hi On 10/07/2015 09:45 PM, Peter Dimov wrote:
Vicente J. Botet Escriba wrote:
Just wondering if we can not make dynamic_pointer_cast to work as your dynamic_moving_pointer_cast, when the parameter is a rvalue reference
template
unique_ptr<T> dynamic_pointer_cast( unique_ptr<U> && r ) noexcept { T * p = dynamic_cast ( r.get() ); if( p ) r.release(); return unique_ptr<T>( p ); }
Agreed. That seems like the best option. On 10/07/2015 09:03 AM, Gavin Lambert wrote:
On 7/10/2015 19:16, Vicente J. Botet Escriba wrote:
Just wondering if we can not make dynamic_pointer_cast to work as your dynamic_moving_pointer_cast, when the parameter is a rvalue reference
It would theoretically be possible if you have access to the internals of shared_ptr (otherwise it would be no better than copying).
We do have access to the internals of the boost smart pointers, so we could provide a set of specialized moving casts for std::unique_ptr, boost::shared_ptr and boost::scoped_ptr. For std::shared_ptr and the other pointers we might still emulate a moving cast in order to facilitate generic programming. Best, Karolin