Om
giveable.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Giveable_
16 
17  #include "om/giveable.hpp"
18 
19 #else
20 
21 // MARK: - Om::Giveable
22 
23  #define Type_ \
24  Om::Giveable
25 
26 // MARK: public (non-static)
27 
28 inline Type_::~Giveable() {}
29 
30  #undef Type_
31 
32 // MARK: - Om::
33 
34 template <typename TheGiveable>
35 inline std::auto_ptr<TheGiveable> Om::Give(TheGiveable & theGiveable) {
36  return Move(theGiveable);
37 }
38 
39 template <typename TheGiveable>
40 inline std::auto_ptr<TheGiveable> Om::Give(TheGiveable const & theGiveable) {
41  return Copy(theGiveable);
42 }
43 
44 template <typename TheGiveable>
45 inline std::auto_ptr<TheGiveable> Om::Give(
46  std::auto_ptr<TheGiveable> & theGiveable
47 ) {
48  return theGiveable;
49 }
50 
51 template <typename TheGiveable>
52 inline std::auto_ptr<TheGiveable> Om::Give(
53  std::auto_ptr<TheGiveable> const & theGiveable
54 ) {
55  return (
56  theGiveable.get() ?
57  Give(*theGiveable) :
58  std::auto_ptr<TheGiveable>()
59  );
60 }
61 
62 #endif
Om header file.
std::auto_ptr< TheMoveable > Move(TheMoveable &)
std::auto_ptr< TheGiveable > Give(TheGiveable &)
Calls Move on the object.
std::auto_ptr< TheCopyable > Copy(TheCopyable const &)