I'm trying to implement an efficient and error free way to perform downcasting of a unique_ptr<Base>
to a derived class unique_ptr<Derived>
. Reading some posts I found that something like this can work (simple dynamic_cast). However, in this other post they say that to perform the downcasting properly the deleter has to be extracted and reassigned.
I'd like to know when it is important to extract the deleter and how should I implement that, since in the answer the just provide the template function with the Del
type, but I don't understand how to use this type in an actual implementation.
EDIT:
More specifically, I do not understand what exactly is the Del
type and how to set it in an actual example. I understand that it is related to the deleter, but I don't know how to define and use it. Since this is not clear to me by only reading this, I'd like some more explanation.