提交 e16b57b0 编写于 作者: P Palana

Add missing copy/move operations for OBSObj

上级 572401fd
......@@ -77,6 +77,8 @@ template<typename T, void destroy(T)> class OBSObj {
public:
inline OBSObj() : obj(nullptr) {}
inline OBSObj(T obj_) : obj(obj_) {}
inline OBSObj(const OBSObj&) = delete;
inline OBSObj(OBSObj &&other) : obj(other.obj) { other.obj = nullptr; }
inline ~OBSObj() {destroy(obj);}
......@@ -87,6 +89,15 @@ public:
obj = obj_;
return *this;
}
inline OBSObj &operator=(const OBSObj&) = delete;
inline OBSObj &operator=(OBSObj &&other)
{
if (obj)
destroy(obj);
obj = other.obj;
other.obj = nullptr;
return *this;
}
inline operator T() const {return obj;}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册