
30 Oct
2005
30 Oct
'05
7:30 p.m.
Hi, I was wondering what the recommended way was to downcast shared pointers. I have a a base class, Base, and a derived class Derived. I have a Base shared pointer which points to a Derived object. shared_ptr<Base> d; As part of a unit test, I'm trying to extract the Derived object from it. *static_cast<Derived *>(d.get()); Here I'm extracting the raw pointer, downcasting it to Derived, and then taking the value. It would be nice if there was some method to downcast the shared_ptr itself. Thanks in advance. Please CC me on any reply. Faheem.
7162
Age (days ago)
7162
Last active (days ago)
0 comments
1 participants
participants (1)
-
Faheem Mitha