Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] Moving cast for unique_ptr
From: Peter Dimov (lists_at_[hidden])
Date: 2015-10-07 15:45:55


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

Yes, that was my first thought as well.

template<class T, class U>
    unique_ptr<T> dynamic_pointer_cast( unique_ptr<U> && r ) noexcept
{
    T * p = dynamic_cast<T*>( r.get() );
    if( p ) r.release();
    return unique_ptr<T>( p );
}


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