Selaa lähdekoodia

2010-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Added SharedHandle::swap
	* src/SharedHandle.h
Tatsuhiro Tsujikawa 15 vuotta sitten
vanhempi
commit
de8598b63a
2 muutettua tiedostoa jossa 17 lisäystä ja 0 poistoa
  1. 5 0
      ChangeLog
  2. 12 0
      src/SharedHandle.h

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2010-11-15  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Added SharedHandle::swap
+	* src/SharedHandle.h
+
 2010-11-14  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Use --max-connection-per-server option value for Metalink.

+ 12 - 0
src/SharedHandle.h

@@ -37,6 +37,7 @@
 
 #include <cassert>
 #include <iosfwd>
+#include <algorithm>
 
 // To Use std::tr1::shared_ptr uncomment following few lines and
 // comment out SharedHandle stuff.
@@ -120,6 +121,11 @@ public:
   }
 
   inline size_t getRefCount() const { return refCount_->getStrongRefCount(); }
+
+  void swap(SharedCount& r)
+  {
+    std::swap(refCount_, r.refCount_);
+  }
 };
 
 class WeakCount {
@@ -273,6 +279,12 @@ public:
   void reset(T* t) {
     *this = SharedHandle(t);
   }
+
+  void swap(SharedHandle& other)
+  {
+    std::swap(obj_, other.obj_);
+    ucount_.swap(other.ucount_);
+  }
 };
 
 template<typename T, typename S>