#include <optional.h>
Specialization to store lvalue references, which only uses a single pointer internally. This can be used to treat pointers that may be null as optional references for more descriptive interfaces.
Public Types | |
| using | ValueType = T & |
| template<typename SUPER > | |
| using | ResultFunctions = maxon::details::ResultOptFunctions< SUPER > |
Public Member Functions | |
| Opt () | |
| MAXON_IMPLICIT | Opt (NO_VALUE_TYPE) |
| Opt (const Opt &src) | |
| Opt & | operator= (const Opt &src) |
| MAXON_IMPLICIT | Opt (T &value) |
| Opt & | operator= (T &value) |
| MAXON_IMPLICIT | Opt (T *valuePtr) |
| Opt & | operator= (T *valuePtr) |
| Bool | HasValue () const |
| Bool | operator== (std::nullptr_t) const |
| Bool | operator!= (std::nullptr_t) const |
| operator Bool () const | |
| Result< T & > | GetValue () const |
| T & | GetValueOr (T &defaultValue) const |
| const T & | GetValueOr (const T &defaultValue) const |
| T | GetValueOr (T &&defaultValue) const |
| const T & | GetValueOrDefault () const |
| MAXON_ATTRIBUTE_FORCE_INLINE const T & | GetValueOrNull () const |
| T * | operator-> () const |
| T & | operator* () const |
| T * | ToPointer () const |
| template<typename TT , typename = typename std::enable_if<std::is_same<const TT, const T>::value || std::is_base_of<TT, T>::value>::type> | |
| operator TT * () const | |
| SFINAEHelper< String, T >::type | ToString (const FormatStatement *format=nullptr) const |
| HashInt | GetHashCode () const |
Private Member Functions | |
| MAXON_ATTRIBUTE_FORCE_INLINE void | CheckValue () const |
Private Attributes | |
| T * | _dataPtr |
| using ValueType = T& |
| using ResultFunctions = maxon::details::ResultOptFunctions<SUPER> |
| Opt | ( | ) |
Default constructor. Creates an Optional with no value.
Explicit construction with NO_VALUE. Has the same effect as the default constructor.
| MAXON_IMPLICIT Opt | ( | T & | value | ) |
Constructs from reference.
| MAXON_IMPLICIT Opt | ( | T * | valuePtr | ) |
Constructs from raw pointer.
| Opt& operator= | ( | T & | value | ) |
Assign from reference.
| Opt& operator= | ( | T * | valuePtr | ) |
Assign from raw pointer.
| Bool HasValue | ( | ) | const |
Returns true if this object contains a value.
| Bool operator== | ( | std::nullptr_t | ) | const |
| Bool operator!= | ( | std::nullptr_t | ) | const |
|
explicit |
| Result<T&> GetValue | ( | ) | const |
Returns the contained value, or IllegalState error if object contained no value.
| T& GetValueOr | ( | T & | defaultValue | ) | const |
Returns the contained value, or a default value if object contained no value.
| const T& GetValueOr | ( | const T & | defaultValue | ) | const |
Returns the contained value, or a default value if object contained no value.
| T GetValueOr | ( | T && | defaultValue | ) | const |
Returns the contained value, or a default value if object contained no value.
| const T& GetValueOrDefault | ( | ) | const |
Returns the contained value, or a default value if object contained no value.
| MAXON_ATTRIBUTE_FORCE_INLINE const T& GetValueOrNull | ( | ) | const |
| T* operator-> | ( | ) | const |
Returns a pointer to the contained value. Results in undefined behavior if object contained no value.
| T& operator* | ( | ) | const |
Returns a reference to the contained value. Results in undefined behavior if object contained no value.
| T* ToPointer | ( | ) | const |
| operator TT * | ( | ) | const |
Converts the optional reference to a raw pointer. This is supported for interoperability with legacy code.
| SFINAEHelper<String, T>::type ToString | ( | const FormatStatement * | format = nullptr | ) | const |
Returns a formated string representation of this optional value.
| HashInt GetHashCode | ( | ) | const |
|
private |
|
private |