Add missing copy/move operations for OBSObj

master
Palana 2014-10-29 14:37:53 +01:00
parent 572401fd80
commit e16b57b076
1 changed files with 11 additions and 0 deletions

View File

@ -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;}