Boost logo

Boost :

From: Dirk Gregorius (dirk_at_[hidden])
Date: 2004-12-03 10:59:10


how can I upcast a shared_ptr?

class Base { /* ... */ }
class Derived : public Base { /* ... */ }

shared_ptr<Base> Get( const char* pName );

shared_ptr<Derived> spDerived = *_cast<*>( Get( "Derived" ) ); // What
do I need to write instead the * ?

Depending on the passed name I like to upcast the returned pointer to a
pointer to the derived class. I used a static_cast with raw pointers
before. What do I have to use with shared_ptr? Do I need to enable RTTI?



Boost list run by bdawes at, gregod at, cpdaniel at, john at