OSDN Git Service

swappable を追加
authorSubaruG <subaru_g@users.sourceforge.jp>
Sun, 7 Feb 2010 07:25:18 +0000 (16:25 +0900)
committerSubaruG <subaru_g@users.sourceforge.jp>
Sun, 7 Feb 2010 07:25:18 +0000 (16:25 +0900)
gintenlib/swappable.hpp [new file with mode: 0644]

diff --git a/gintenlib/swappable.hpp b/gintenlib/swappable.hpp
new file mode 100644 (file)
index 0000000..5705394
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef GINTENLIB_INCLUDED_SWAPPABLE_HPP_
+#define GINTENLIB_INCLUDED_SWAPPABLE_HPP_
+
+/*
+
+      <gintenlib/swappable.hpp>
+
+  swappable : friend 版 swap の自動定義
+
+  宣言:
+    template< typename Derived >
+    class swappable
+    {
+      friend void swap( Derived& one, Derived& another );
+    };
+
+  機能:
+    one.swap( another ); を呼び出す friend 関数 swap を定義します
+  
+*/
+
+namespace gintenlib
+{
+ namespace swappable_ // ADL 対策
+ {
+  // 使い方: class hoge : gintenlib::swappable<hoge>
+  template<typename Derived>
+  class swappable
+  {
+    friend void swap( Derived& one, Derived& another )
+    {
+      one.swap( another );
+    }
+    
+  };  // struct swappable
+  
+ }  // namespace swappable_
+ // ADL 対策
+ using namespace swappable_;
+
+} // namespace gintenlib
+
+#endif  // #ifndef GINTENLIB_INCLUDED_SWAPPABLE_HPP_