]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/containers/copy_functors.hpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / containers / copy_functors.hpp
diff --git a/src/stlplus/containers/copy_functors.hpp b/src/stlplus/containers/copy_functors.hpp
new file mode 100644 (file)
index 0000000..c82ee9f
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef STLPLUS_COPY_FUNCTORS\r
+#define STLPLUS_COPY_FUNCTORS\r
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+//   Author:    Andy Rushton\r
+//   Copyright: (c) Southampton University 1999-2004\r
+//              (c) Andy Rushton           2004-2009\r
+//   License:   BSD License, see ../docs/license.html\r
+\r
+//   The function constructor classes below are used by the smart_ptr and the\r
+//   simple_ptr classes. They provide three (well ok, two) copying mechanisms.\r
+//   These classes have been separated from the smart_ptr header by DJDM, as\r
+//   the simple_ptr classes now also use them.\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+#include "containers_fixes.hpp"\r
+#include "exceptions.hpp"\r
+\r
+namespace stlplus\r
+{\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+  // copy functors implementing the three possible copy semantics\r
+\r
+  // constructor_copy uses the copy constructor of the object - used for simple types\r
+\r
+  template <typename T>\r
+  class constructor_copy\r
+  {\r
+  public:\r
+    T* operator() (const T& from) throw()\r
+      {\r
+        return new T(from);\r
+      }\r
+  };\r
+\r
+  // clone_copy uses the clone method of the object - used for polymorphic types\r
+\r
+  template <typename T>\r
+  class clone_copy\r
+  {\r
+  public:\r
+    T* operator() (const T& from) throw()\r
+      {\r
+        return from.clone();\r
+      }\r
+  };\r
+\r
+  // no_copy throws an exception - used for types that cannot be copied\r
+\r
+  template <typename T>\r
+  class no_copy\r
+  {\r
+  public:\r
+    T* operator() (const T& from) throw(illegal_copy)\r
+      {\r
+        throw illegal_copy("no_copy functor called");\r
+        return 0;\r
+      }\r
+  };\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+} // end namespace stlplus\r
+\r
+#endif\r
This page took 0.022968 seconds and 4 git commands to generate.