Om
owner.hpp
Go to the documentation of this file.
1 
15 #ifndef Om_Owner_
16 
17  #define Om_Owner_ \
18  Om::Owner
19 
20  #include "om/taker.hpp"
21 
22  #ifndef Om_Macro_Precompilation_
23 
24  #include <memory>
25  #include "boost/intrusive_ptr.hpp"
26 
27  #endif
28 
29 namespace Om {
30 
31  // MARK: - Om::Owner
32 
39  template <typename ThisValue>
40  class Owner:
41  public Taker<
42  Owner<ThisValue>
43  > {
44 
45  public: // MARK: public (static)
46 
51  typedef void (Owner::* Boolean)() const;
52 
53  public: // MARK: public (non-static)
54 
55  Owner();
56 
57  Owner(Owner const &);
58 
59  template <typename TheValue>
60  explicit Owner(
61  std::auto_ptr<TheValue>
62  );
63 
69 
76  ThisValue & operator *();
77 
81  ThisValue const & operator *() const;
82 
83  ThisValue * operator ->();
84 
85  ThisValue const * operator ->() const;
86 
91  bool operator !() const;
92 
97  operator Boolean() const;
98 
103  void Clear();
104 
105  ThisValue * GetValue();
106 
107  ThisValue const * GetValue() const;
108 
113  bool IsEmpty() const;
114 
119  template <typename TheValue>
120  void SetValue(
121  std::auto_ptr<TheValue>
122  );
123 
128  void Swap(Owner &);
129 
130  private: // MARK: private (non-static)
131 
132  void UncomparableBoolean() const;
133 
138  boost::intrusive_ptr<ThisValue> thisValue;
139 
145 
146  };
147 
148 }
149 
150 namespace boost {
151 
152  // MARK: - boost::
153 
154  template <typename TheValue>
155  void swap(
158  );
159 
160 }
161 
162  #include "om/owner.cpp"
163 
164 #endif
A polymorphic object with value semantics.
Definition: owner.hpp:43
void Clear()
bool operator!() const
void SetValue(std::auto_ptr< TheValue >)
bool IsEmpty() const
Owner(std::auto_ptr< TheValue >)
ThisValue const * GetValue() const
ThisValue * operator->()
Owner & operator=(Owner)
void UncomparableBoolean() const
boost::intrusive_ptr< ThisValue > thisValue
The pointer to the contained, lazily-copied value.
Definition: owner.hpp:138
ThisValue * GetValue()
bool thisWasExposed
True if the contained value was exposed for modification.
Definition: owner.hpp:144
void(Owner::* Boolean)() const
The implementation of the Safe Boolean idiom.
Definition: owner.hpp:51
ThisValue & operator*()
Owner(Owner const &)
void Swap(Owner &)
An object that can take (copy or swap) another of the same type.
Definition: taker.hpp:29
The Om library.
Definition: code_point.hpp:26
void swap(Om::Language::Expression &, Om::Language::Expression &)
Om source file.
Om header file.