标签:整理 ++ 需要 三方 调用 void eth 抽象 本质
void* p = GetHandle()->Create();
//do something...
GetHandle()->Release(p);
void* p = GetHandle()->Create();
std::shared_ptr<void> sp(p,[this](void*p){GetHandle()->Release(p);});
std::shared_ptr<void> Guard(void* p)
{
return std::shared_ptr<void> sp(p,[this](void* p){GetHandle()->Release(p);});
}
void* p = GetHandle()->Create();
auto sp = Guard(p);
//do something...
#define GUARD(P) std::shared_ptr<void> p##p(p,[](void* p){GetHandle()->Release(p);});
void *p = GetHandle()->Create();
GUARD(p);//安全
#define GUARD(P) std::unique_ptr<void,void(*)(int *) > p##p(p,[](void* p){GetHandle()->Release(p);});
标签:整理 ++ 需要 三方 调用 void eth 抽象 本质
原文地址:https://www.cnblogs.com/fewolflion/p/12960316.html