|
Boost Users : |
From: Olaf Petzold (yg-boost-users_at_[hidden])
Date: 2002-08-26 10:18:37
Thank you,
>> 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 );
I want to swap the pointers inside for further use (for saving the old ptr
contents and restoring for circumstances - clone() may be one way before
set() it but has overhead).
Regards
Olaf
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net