Thursday, 22 August 2013

What is the correct way to cast a std::unique_ptr to a std::unique_ptr to a superclass?

What is the correct way to cast a std::unique_ptr to a std::unique_ptr to
a superclass?

Suppose I have a class called foo which inherits from a class called bar.
I have a std::unique_ptr to an instance of foo and I want to pass it to a
function that only takes std::unique_ptr<bar>. How can I cast the pointer
so it works in my function?

No comments:

Post a Comment