Using std::unique_ptr for down cast

Flaviu_ 666 Reputation points

What is the correct usage of std::unique_ptr for converting to base class a derived class ?

std::unique_ptr<Base*> SomeMethod()
    return std::unique_ptr<Derived*>(new Derived());
    return std::make_unique<Base*>(new Derived());


A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,191 questions
{count} votes