25 #ifndef __TPIE_MAYBE_H__
26 #define __TPIE_MAYBE_H__
29 #include <tpie/config.h>
39 maybe() : m_constructed(false) {
46 o.assert_not_constructed();
50 o.assert_not_constructed();
54 void assert_not_constructed()
const {
56 throw maybe_exception(
"Maybe object already constructed");
64 o.assert_not_constructed();
65 assert_not_constructed();
71 o.assert_not_constructed();
72 assert_not_constructed();
97 template <
typename ... T_ARGS>
99 assert_not_constructed();
101 new(&object) T(std::forward<T_ARGS>(t)...);
102 m_constructed =
true;
141 m_constructed =
false;
maybe(const maybe< T > &o)
If o is constructed throw an exception otherwise do nothing.
bool is_constructed() const
void destruct()
Invokes the deconstructor on the object contained.
maybe & operator=(const maybe< T > &o)
If o is constructed throw an exception otherwise return *this.
~maybe()
Calls the destruct method and destroys the instance.
void construct(T_ARGS &&...t)
Contains an element of the type given as template parameter and disallows copy constructing of the ma...
const T & operator*() const
const T * operator->() const
maybe()
Construct a new unconstructed maybe object.