std::tr1::shared_ptr<Book> spb = std::tr1::dynamic_pointer_cast<Book>(spi); if(spb) std::cout << spb->Title() << ", " << spb->Pages() << " pages" << std::endl; std::tr1::shared_ptr<DVD> spd = std::tr1::dynamic_pointer_cast<DVD>(spi); if(spd) std::cout << ...
shared_ptr<SIPProtocol> sip;//首先声明子类的强引用指针SProtocol sp=ingress.GetUDPProtocol();//获取到父类的强引用指针sip=dynamic_pointer_cast<SIPProtocol>(sp);//强转得到子类的强引用指针ingress.NewUDPProtocol(APP_PROTOCOL_SIP);
ServiceDiscovery::ref sd=serviceDiscovery.lock();if(!sd)return; DiscoItem::ref c=boost::dynamic_pointer_cast<DiscoItem> (cursorPos);if(c) { sd->discoverJid(c->jid, c->node); sd->go();return; } DiscoCommand::ref dc=boost::dynamic_pointer_cast<DiscoCommand> (cursorPos);if(dc) {...
boolis_root()constnoexcept{if(node.expired()) {returnfalse; }returnbool{std::dynamic_pointer_cast<node::inu>(node.lock())}; } 开发者ID:rhysd,项目名称:Dachs,代码行数:7,代码来源:ast_fwd.hpp 示例2: exit ▲点赞 6▼ Listener::Listener(conststd::weak_ptr<Manager>& manager){ LOG_ENTER...
std::dynamic_pointer_cast std::enable_if std::enable_shared_from_this std::enable_shared_from_this::enable_shared_from_this std::enable_shared_from_this::shared_from_this std::enable_shared_from_this::weak_from_this std::end(std::initializer_list) std::equal_to std::equal_to<void> ...
D* d = dynamic_cast<D*>(b); //这是使用get的正当理由吗? 正确的做法 shared_ptr<B> spb (new D) ; shared_ptr<D> spd = shared_dynamic_cast<D>(spb); //变成子类的指针 shared_ptr在竭尽全力表演的像一个原生指针,原生指针能干的事,它也基本上能干。
1,因此得不到释放,RAII 此时也无能为力。这时就需要使用 weak_ptr 来打破循环引用。
{ CBasePtr ptrBase = boost::make_shared(); //CBasePtr ptrBase = CBasePtr(new CBase()); // 向下转换 CChildPtr ptrChild = boost::dynamic_pointer_cast(ptrBase); // 向上转换 CBasePtr ptrXXX = ptrChild; // 普通转换 CChildPtr ptrXX = CChildPtr(dynamic_cast(ptrXXX.get())); }...
{ }struct__static_cast_tag { };struct__const_cast_tag { };struct__dynamic_cast_tag { };//A smart pointer with reference-counted copy semantics. The//object pointed to is deleted when the last shared_ptr pointing to//it is destroyed or reset.template<typename _Tp, _Lock_policy _Lp...
{std::shared_ptr<T> new_type =std::dynamic_pointer_cast<T>(lp);if(new_type)returnnew_type; }returnnullptr; }// get 开发者ID:toymak3r,代码行数:11, 示例3: handleWriteTimeout ▲点赞 3▼ voidConnection::handleWriteTimeout(std::weak_ptr<Connection> weak,constboost::system::error_code...