我的代码需要范围守卫,但是我必须手动Dismiss()
所有范围守卫通常退出功能?即ScopeGuard解雇
void Deleter(MyClass* obj)
{
delete obj;
}
MyClass* Func()
{
MyClass* obj = new MyClass();
ScopeGuard sg1 = MakeObjGuard(Deleter, obj);
//More objects created. And more scope guards.
sg1.Dismiss();
//...Same for other guards
return obj;
}
ScopeGuard和MakeObjGuard的定义是什么? – 2011-03-11 06:02:34
http://drdobbs.com/184403758 – nakiya 2011-03-11 06:05:32
你最好只用'std :: auto_ptr obj(new MyClass); ... return obj.release();' –
MSalters
2011-03-11 10:25:40