|
RTI Connext Modern C++ API
Version 6.0.1
|
<<value-type>> Represents an object that may not contain a valid value More...
#include <dds/core/Optional.hpp>
Public Member Functions | |
| optional () OMG_NOEXCEPT | |
| Create an unset optional object. | |
| optional (const T &value) | |
| Create an optional object with a copy of a value. | |
| optional (T &&value) | |
| <<C++11>> Create an optional object moving a value | |
| optional (bool condition, const T &value) | |
| Create an optional member conditionally set or unset. | |
| optional (bool condition, T &&value) | |
| <<C++11>> Creates an optional member conditionally set or unset by moving a value. | |
| ~optional () | |
| Destroys the underlying object if it exists. | |
| void | set (const T &value) |
| Assigns a copy of an object. | |
| void | set (T &&value) |
| <<C++11>> Assigns an object by moving it | |
| bool | is_set () const OMG_NOEXCEPT |
| Checks if this optional instance contains a valid object. | |
| bool | has_value () const OMG_NOEXCEPT |
| Checks if this optional instance contains a valid object. | |
| operator bool () const OMG_NOEXCEPT | |
| Returns has_value() | |
| void | reset () |
| Destroys the underlying object and leaves this optional with an invalid (unset) value. | |
| const T & | value () const |
| Retrieves the underlying object if it exists. | |
| T & | value () |
| Retrieves the underlying object if it exists. | |
| const T & | get () const |
| Retrieves the underlying object if it exists. | |
| T & | get () |
| Retrieves the underlying object if it exists. | |
| const T * | get_ptr () const |
| Returns &get() if the object is initialized or NULL otherwise. | |
| T * | get_ptr () |
| Returns &get() if the object is initialized or NULL otherwise. | |
| const T & | operator* () const |
| T & | operator* () |
| const T * | operator-> () const |
| T * | operator-> () |
| optional< T > & | operator= (const optional< T > &other) |
| Assignment operator. | |
| optional< T > & | operator= (optional< T > &&other) OMG_NOEXCEPT |
| <<C++11>> Move-assignment operator | |
| optional< T > & | operator= (const T &value) |
| Assign a (valid) value. | |
| optional< T > & | operator= (T &&value) |
| Assign a (valid) value by moving an object. | |
Friends | |
| void | swap (optional< T > &left, optional< T > &right) OMG_NOEXCEPT |
| Swaps the underlying objects. | |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename T > | |
| bool | operator== (const optional< T > &a, const optional< T > &b) |
| Compares two optional values. | |
| template<typename T > | |
| bool | operator!= (const optional< T > &a, const optional< T > &b) |
| Compares two optional values. | |
| template<typename T > | |
| bool | operator== (const optional< T > &optional_value, const T &value) |
| Compares an optional member and a value of the underlying type. | |
| template<typename T > | |
| bool | operator== (const T &value, const optional< T > &optional_value) |
| Compares an optional member and a value of the underlying type. | |
| template<typename T > | |
| bool | operator!= (const optional< T > &optional_value, const T &value) |
| Compares an optional member and a value of the underlying type. | |
| template<typename T > | |
| bool | operator!= (const T &value, const optional< T > &optional_value) |
| Compares an optional member and a value of the underlying type. | |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &out, const optional< T > &optional) |
Applies operator<< to *optional or to the string "NULL" if !optional.has_value(). | |
<<value-type>> Represents an object that may not contain a valid value
| T | The type of the actual object this optional<T> wraps |
Members of an IDL type marked with the @optional tag map to this C++ type.
When an optional value has a valid value has_value() returns true and operator* returns a reference to the actual object of type T. Otherwise has_value() returns false and operator* throws dds::core::PreconditionNotMetError. To assing a value you can use the assignment operator.
An optional object has full value-type semantics; copying an optional value copies the underlying object if it exists.
This type's API is similar to that of std::optional.
|
inline |
Create an unset optional object.
|
inline |
Create an optional object with a copy of a value.
has_value() && *(*this) == value
|
inline |
<<C++11>> Create an optional object moving a value
|
inline |
Create an optional member conditionally set or unset.
| condition | If true creates an optional member with value otherwise it creates an unset optional member |
| value | The value to set if condition is true |
|
inline |
<<C++11>> Creates an optional member conditionally set or unset by moving a value.
Moves the value rather than copying it.
|
inline |
Destroys the underlying object if it exists.
|
inline |
Assigns a copy of an object.
[DEPRECATED] Use operator= instead.
|
inline |
<<C++11>> Assigns an object by moving it
[DEPRECATED] Use operator= instead.
|
inline |
Checks if this optional instance contains a valid object.
[DEPRECATED] Use has_value()
|
inline |
Checks if this optional instance contains a valid object.
If my_optional->has_value(), then *my_optional returns a valid object
|
inline |
Returns has_value()
|
inline |
Destroys the underlying object and leaves this optional with an invalid (unset) value.
|
inline |
Retrieves the underlying object if it exists.
This operation, unlike operator* throws an exception if the underlying object doesn't exist.
| dds::core::PreconditionNotMetError | if !has_value(). |
|
inline |
Retrieves the underlying object if it exists.
This operation, unlike operator* throws an exception if the underlying object doesn't exist.
| dds::core::PreconditionNotMetError | if !has_value(). |
|
inline |
Retrieves the underlying object if it exists.
[DEPRECATED] Use value() or operator*
| dds::core::PreconditionNotMetError | if !has_value(). |
|
inline |
Retrieves the underlying object if it exists.
[DEPRECATED] Use value() or operator*
| dds::core::PreconditionNotMetError | if !has_value(). |
|
inline |
Returns &get() if the object is initialized or NULL otherwise.
[DEPRECATED]
|
inline |
Returns &get() if the object is initialized or NULL otherwise.
[DEPRECATED]
|
inline |
Get the value, without checking if it exists
|
inline |
Get the value, without checking if it exists
|
inline |
Get the value.
| dds::core::PreconditionNotMetError | if !has_value() |
|
inline |
Get the value.
| dds::core::PreconditionNotMetError | if !has_value() |
|
inline |
Assignment operator.
Copies *other if it exists.
|
inline |
<<C++11>> Move-assignment operator
Moves *other if it exists.
|
inline |
Assign a (valid) value.
| value | The value to assign to this optional member |
*(*this) == value
|
inline |
Assign a (valid) value by moving an object.
| value | The value to move into this optional member |
Swaps the underlying objects.
This operation is always O(1).
Compares two optional values.
*a == *b. Compares two optional values.
*a == *b.
|
related |
Compares an optional member and a value of the underlying type.
optional_value is set and *optional_value == value
|
related |
Compares an optional member and a value of the underlying type.
*optional_value == value
|
related |
Compares an optional member and a value of the underlying type.
*optional_value == value
|
related |
Compares an optional member and a value of the underlying type.
*optional_value == value
|
related |
Applies operator<< to *optional or to the string "NULL" if !optional.has_value().