enable_shared_from_this and inheritance
Posted
by
DeadMG
on Stack Overflow
See other posts from Stack Overflow
or by DeadMG
Published on 2010-12-20T16:09:18Z
Indexed on
2012/09/29
3:37 UTC
Read the original article
Hit count: 139
I've got a type which inherits from enable_shared_from_this<type>
, and another type that inherits from this type. Now I can't use the shared_from_this method because it returns the base type and in a specific derived class method I need the derived type. Is it valid to just construct a shared_ptr from this directly?
Edit:
In a related question, how can I move from an rvalue of type shared_ptr<base>
to a type of shared_ptr<derived>
? I used dynamic_cast to verify that it really was the correct type, but now I can't seem to accomplish the actual move.
© Stack Overflow or respective owner