RTI Connext Modern C++ API Version 7.1.0
|
<<extension>> Represents a value that can be initialized or not More...
#include <OptionalValue.hpp>
Public Member Functions | |
optional_value () | |
Creates an uninitialized value. More... | |
optional_value (const T &value) | |
Creates an instance with a value. More... | |
optional_value (bool condition, const T &value) | |
Conditionally creates an instance that can be uninitialized or initialized with a value. More... | |
optional_value (const optional_value< T > &other) | |
Copy constructor. More... | |
bool | is_set () const OMG_NOEXCEPT |
Returns true only if the value is initialized. More... | |
bool | has_value () const OMG_NOEXCEPT |
Returns true only if the value is initialized. More... | |
operator bool () const OMG_NOEXCEPT | |
<<C++11>> Returns has_value() More... | |
void | reset () |
After calling this function, this optional_value is not set. More... | |
const T & | value () const |
Retrieves the underlying object if it exists. More... | |
T & | value () |
Retrieves the underlying object if it exists. More... | |
const T & | get () const |
Retrieves the underlying object if it exists. More... | |
T & | get () |
Retrieves the underlying object if it exists. More... | |
const T & | operator* () const |
T & | operator* () |
const T * | operator-> () const |
T * | operator-> () |
Friends | |
void | swap (optional_value< T > &left, optional_value< T > &right) OMG_NOEXCEPT |
Swaps the underlying objects. More... | |
<<extension>> Represents a value that can be initialized or not
This class is similar to dds::core::optional and std::optional
.
They have different implementations. dds::core::optional is only used in IDL-generated types, while rti::core::optional_value is used in parts of the API.
|
inline |
Creates an uninitialized value.
|
inline |
Creates an instance with a value.
|
inline |
Conditionally creates an instance that can be uninitialized or initialized with a value.
condition | If it is true it assigns value , otherwise this optional_value is uninitialized |
value | The value to use if condition is true. |
References rti::core::optional_value< T >::value().
|
inline |
Copy constructor.
This optional_value will be initialized only if other
is initialized.
References rti::core::optional_value< T >::get(), and rti::core::optional_value< T >::has_value().
|
inline |
Returns true only if the value is initialized.
[DEPRECATED] Use has_value()
|
inline |
Returns true only if the value is initialized.
Referenced by rti::core::optional_value< T >::optional_value(), and rti::core::optional_value< T >::value().
|
inlineexplicit |
<<C++11>> Returns has_value()
|
inline |
After calling this function, this optional_value is not set.
|
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(). |
References rti::core::optional_value< T >::has_value().
Referenced by rti::core::optional_value< T >::get(), rti::core::optional_value< T >::operator->(), and rti::core::optional_value< T >::optional_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(). |
References rti::core::optional_value< T >::has_value().
|
inline |
Retrieves the underlying object if it exists.
[DEPRECATED] Use value() or operator*
dds::core::PreconditionNotMetError | if !has_value(). |
References rti::core::optional_value< T >::value().
Referenced by rti::core::optional_value< T >::optional_value().
|
inline |
Retrieves the underlying object if it exists.
[DEPRECATED] Use value() or operator*
dds::core::PreconditionNotMetError | if !has_value(). |
References rti::core::optional_value< T >::value().
|
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() |
References rti::core::optional_value< T >::value().
|
inline |
Get the value.
dds::core::PreconditionNotMetError | if !has_value() |
References rti::core::optional_value< T >::value().
|
friend |
Swaps the underlying objects.
It uses swap(*left, *right)
if that function is defined for type T
; otherwise it uses std::swap
.