Jelajahi Sumber

HPCC-14787 Add a move constructor to Shared<X>

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 tahun lalu
induk
melakukan
9911b2efe0
1 mengubah file dengan 4 tambahan dan 3 penghapusan
  1. 4 3
      system/jlib/jscm.hpp

+ 4 - 3
system/jlib/jscm.hpp

@@ -85,7 +85,6 @@ private:
     CLASS * ptr;
 };
 
-
 //This base class implements a shared pointer based on a link count held in the object.
 //The two derived classes Owned and Linked should be used as the concrete types to construct a shared object
 //from a pointer.
@@ -94,9 +93,11 @@ template <class CLASS> class Shared
 public:
     inline Shared()                              { ptr = NULL; }
     inline Shared(CLASS * _ptr, bool owned)      { ptr = _ptr; if (!owned && _ptr) _ptr->Link(); }
-    inline Shared(const Shared<CLASS> & other)   { ptr = other.getLink(); }
+    inline Shared(const Shared & other)          { ptr = other.getLink(); }
+#if defined(__cplusplus) and __cplusplus >= 201100
+    inline Shared(Shared && other)               { ptr = other.getClear(); }
+#endif
     inline ~Shared()                             { ::Release(ptr); }
-
     inline Shared<CLASS> & operator = (const Shared<CLASS> & other) { this->set(other.get()); return *this;  }
 
     inline CLASS * operator -> () const         { return ptr; }