This class manages an optional contained value, i.e. More...
Public Types | |
| typedef optional< T > | _self_type |
| Type for the optional class itself. More... | |
Public Member Functions | |
| constexpr | optional (std::nullptr_t) |
| Create a disengaged object. More... | |
| constexpr | optional () |
| Default constructor. More... | |
| optional (T &&other) | |
Create an engaged object by moving other content. More... | |
| optional (T const &other) | |
Create an engaged object by copying other content. More... | |
| template<typename U > | |
| optional (U &&other, typename std::enable_if< std::is_convertible< U, T >::value >::type *=0) | |
Create an engaged object by moving other content. More... | |
| template<typename U > | |
| optional (U const &other, typename std::enable_if< std::is_convertible< U, T >::value >::type *=0) | |
Create an engaged object by copying other content. More... | |
| optional (optional< T > const &other) | |
| Copy constructor. More... | |
| optional (optional< T > &&other) | |
| Move constructor. More... | |
| template<typename U > | |
| optional (optional< U > &&other, typename std::enable_if< std::is_convertible< U, T >::value >::type *=0) | |
| Move constructor. More... | |
| template<typename U > | |
| optional (optional< U > const &other, typename std::enable_if< std::is_convertible< U, T >::value >::type *=0) | |
| Copy constructor. More... | |
| _self_type & | operator= (optional< T > &&other) |
| Assign new content to the object. More... | |
| _self_type & | operator= (optional< T >const &other) |
| Assign new content to the object. More... | |
| template<typename U > | |
| std::enable_if< std::is_convertible< U, T >::value, _self_type >::type & | operator= (optional< U > &&other) |
| Assign new content to the object. More... | |
| template<typename U > | |
| std::enable_if< std::is_convertible< U, T >::value, _self_type >::type & | operator= (optional< U >const &other) |
| Assign new content to the object. More... | |
| void | disengage () |
| Disengage the object, destroying the current contained value, if any. | |
| ~optional () | |
| Releases the contained value if the object is engaged. | |
| operator bool () const | |
Convert to bool based on whether the object is engaged or not. More... | |
| bool | operator! () const |
Convert to bool based on whether the object is engaged or not. More... | |
| T * | operator-> () |
| Access member of the contained value. More... | |
| T const * | operator-> () const |
| Access constant member of the contained value. More... | |
| T & | operator* () |
| Get the contained value. More... | |
| T const & | operator* () const |
| Get the contained value. More... | |
| T & | get () |
| Get the contained value. More... | |
| T const & | get () const |
| Get the contained value. More... | |
| void | swap (optional< T > &other) |
Swap content with another eina::optional object. More... | |
| bool | is_engaged () const |
| Check if the object is engaged. More... | |
This class manages an optional contained value, i.e.
a value that semantically may not be present.
A common use case for optional is the return value of a function that may fail. As opposed to other approaches, such as std::pair<T,bool>, optional handles expensive to construct objects well and is more readable, as the intent is expressed explicitly.
An optional object holding a semantically present value is considered to be engaged, otherwise it is considered to be disengaged.
| typedef optional<T> efl::eina::optional< T >::_self_type |
Type for the optional class itself.
|
inline |
Create a disengaged object.
This constructor creates a disengaged eina::optional object.
|
inline |
Default constructor.
Create a disengaged object.
|
inline |
Create an engaged object by moving other content.
| other | R-value reference to the desired type. |
This constructor creates an eina::optional object in an engaged state. The contained value is initialized by moving other.
|
inline |
Create an engaged object by copying other content.
| other | Constant reference to the desired type. |
This constructor creates an eina::optional object in an engaged state. The contained value is initialized by copying other.
|
inline |
Create an engaged object by moving other content.
| other | R-value reference to the desired type. |
This constructor creates an eina::optional object in an engaged state. The contained value is initialized by moving other.
|
inline |
Create an engaged object by copying other content.
| other | Constant reference to the desired type. |
This constructor creates an eina::optional object in an engaged state. The contained value is initialized by copying other.
|
inline |
Copy constructor.
Create an object containing the same value as other and in the same state.
| other | Constant reference to another eina::optional object that holds the same value type. |
This constructor creates an eina::optional object with the same engagement state of other. If other is engaged then the contained value of the newly created object is initialized by copying the contained value of other.
|
inline |
Move constructor.
Create an object containing the same value as other and in the same state.
| other | R-value reference to another eina::optional object that holds the same value type. |
This constructor creates an eina::optional object with the same engagement state of other. If other is engaged then the contained value of the newly created object is initialized by moving the contained value of other.
|
inline |
Move constructor.
Create an object containing the same value as other and in the same state.
| other | R-value reference to another eina::optional object that holds a different, but convertible, value type. |
This constructor creates an eina::optional object with the same engagement state of other. If other is engaged then the contained value of the newly created object is initialized by moving the contained value of other.
|
inline |
Copy constructor.
Create an object containing the same value as other and in the same state.
| other | Constant reference to another eina::optional object that holds a different, but convertible, value type. |
This constructor creates an eina::optional object with the same engagement state of other. If other is engaged then the contained value of the newly created object is initialized by converting and copying the contained value of other.
References efl::eina::optional< T >::is_engaged().
|
inline |
Assign new content to the object.
| other | R-value reference to another eina::optional object that holds the same value type. |
This operator replaces the current content of the object. If other is engaged its contained value is moved to this object, making *this be considered engaged too. If other is disengaged *this is also made disengaged and its contained value, if any, is simple destroyed.
|
inline |
Assign new content to the object.
| other | Constant reference to another eina::optional object that holds the same value type. |
This operator replaces the current content of the object. If other is engaged its contained value is copied to this object, making *this be considered engaged too. If other is disengaged *this is also made disengaged and its contained value, if any, is simple destroyed.
References efl::eina::optional< T >::swap().
|
inline |
Assign new content to the object.
| other | R-value reference to another eina::optional object that holds a different, but convertible, value type. |
This operator replaces the current content of the object. If other is engaged its contained value is moved to this object, making *this be considered engaged too. If other is disengaged *this is also made disengaged and its contained value, if any, is simple destroyed.
|
inline |
Assign new content to the object.
| other | Constant reference to another eina::optional object that holds a different, but convertible, value type. |
This operator replaces the current content of the object. If other is engaged its contained value is converted and copied to this object, making *this be considered engaged too. If other is disengaged *this is also made disengaged and its contained value, if any, is simple destroyed.
References efl::eina::optional< T >::is_engaged().
|
inlineexplicit |
Convert to bool based on whether the object is engaged or not.
true if the object is engaged, false otherwise.
|
inline |
Convert to bool based on whether the object is engaged or not.
true if the object is disengaged, false otherwise.
|
inline |
Access member of the contained value.
|
inline |
Access constant member of the contained value.
|
inline |
Get the contained value.
|
inline |
Get the contained value.
|
inline |
Get the contained value.
|
inline |
Get the contained value.
|
inline |
Swap content with another eina::optional object.
| other | Another eina::optional object. |
References efl::eina::optional< T >::is_engaged().
Referenced by efl::eina::optional< T >::operator=(), and efl::eina::swap().
|
inline |
Check if the object is engaged.
true if the object is currently engaged, false otherwise. Referenced by efl::eina::optional< T >::operator=(), efl::eina::optional< T >::optional(), and efl::eina::optional< T >::swap().