static_cast
と同等のものは何ですかboost::shared_ptr
?
言い換えれば、次の文をどのように書き直せばいいのでしょうか
Base* b = new Derived();
Derived* d = static_cast<Derived*>(b);
使用時shared_ptr
は?
boost::shared_ptr<Base> b(new Derived());
boost::shared_ptr<Derived> d = ???
ベストアンサー1
使用boost::static_pointer_cast
:
boost::shared_ptr<Base> b(new Derived());
boost::shared_ptr<Derived> d = boost::static_pointer_cast<Derived>(b);