]> Dogcows Code - chaz/yoink/blob - src/stlplus/containers/copy_functors.hpp
cleanup stlplus files
[chaz/yoink] / src / stlplus / containers / copy_functors.hpp
1 #ifndef STLPLUS_COPY_FUNCTORS
2 #define STLPLUS_COPY_FUNCTORS
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // The function constructor classes below are used by the smart_ptr and the
11 // simple_ptr classes. They provide three (well ok, two) copying mechanisms.
12 // These classes have been separated from the smart_ptr header by DJDM, as
13 // the simple_ptr classes now also use them.
14
15 ////////////////////////////////////////////////////////////////////////////////
16 #include "containers_fixes.hpp"
17 #include "exceptions.hpp"
18
19 namespace stlplus
20 {
21
22 ////////////////////////////////////////////////////////////////////////////////
23 // copy functors implementing the three possible copy semantics
24
25 // constructor_copy uses the copy constructor of the object - used for simple types
26
27 template <typename T>
28 class constructor_copy
29 {
30 public:
31 T* operator() (const T& from) throw()
32 {
33 return new T(from);
34 }
35 };
36
37 // clone_copy uses the clone method of the object - used for polymorphic types
38
39 template <typename T>
40 class clone_copy
41 {
42 public:
43 T* operator() (const T& from) throw()
44 {
45 return from.clone();
46 }
47 };
48
49 // no_copy throws an exception - used for types that cannot be copied
50
51 template <typename T>
52 class no_copy
53 {
54 public:
55 T* operator() (const T& from) throw(illegal_copy)
56 {
57 throw illegal_copy("no_copy functor called");
58 return 0;
59 }
60 };
61
62 ////////////////////////////////////////////////////////////////////////////////
63
64 } // end namespace stlplus
65
66 #endif
This page took 0.029869 seconds and 4 git commands to generate.