26 Aug
2002
26 Aug
'02
2:30 p.m.
From: "Olaf Petzold"
struct C : public BaseC { C() : b( new B("C::b") ) { } void set(const boost::shared_ptr<A>& ptr) { b.swap( boost::shared_static_cast<B>( ptr ) ); // L21 } void print() { std::cout << b->name << std::endl; } boost::shared_ptr<B> b; };
Why not simply b = boost::shared_static_cast<B>( ptr ); or b = boost::shared_polymorphic_cast<B>( ptr ); ?