shared_ptr的reset问题
#include<iostream>#include<boost/smart_ptr.hpp>usingnamespacestd;usingnamespaceboost;...
#include <iostream>
#include <boost/smart_ptr.hpp>
using namespace std;
using namespace boost;
int main(void)
{
boost::shared_ptr<std::exception> p1(new std::bad_exception("abc"));
boost::shared_ptr<std::bad_exception> p2 = dynamic_pointer_cast<std::bad_exception>(p1);
boost::shared_ptr<std::exception> p3 = dynamic_pointer_cast<std::exception>(p2);
assert(p1 == p3);
cout<<p3.use_count()<<endl;
p3.reset();//这句有问题
system("pause");
}
不知道这句为啥不对 展开
#include <boost/smart_ptr.hpp>
using namespace std;
using namespace boost;
int main(void)
{
boost::shared_ptr<std::exception> p1(new std::bad_exception("abc"));
boost::shared_ptr<std::bad_exception> p2 = dynamic_pointer_cast<std::bad_exception>(p1);
boost::shared_ptr<std::exception> p3 = dynamic_pointer_cast<std::exception>(p2);
assert(p1 == p3);
cout<<p3.use_count()<<endl;
p3.reset();//这句有问题
system("pause");
}
不知道这句为啥不对 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询