我在代码中使用了boost'intrusive_ptr'但是当我删除一些对象时,我遇到了崩溃!
事实上我在一个类中使用相同的'intrusive_ptr'并返回它,如下所示:
typedef intrusive_ptr<Node> ref;
class MyContainer
{
ref SmartPointer;
};
class Compiler
{
private:
ref MyNode;
public:
ref getMyNode() { return MyNode; }
ref process() {MyNode.Reset(); ... return MyNode; }
};
MyContainer * c1 = new MyContainer();
c1->SmartPointer = compiler.process();
delete c1; <= CRASH