RTI Connext Modern C++ API Version 7.3.0
|
A result from an operation that doesn't throw exceptions containing a return code and (if successful) a value. More...
#include <Result.hpp>
Public Member Functions | |
Result ()=default | |
Creates a Result object with a return code of DDS_RETCODE_ERROR and no value. More... | |
Result (const T &value) | |
Creates a Result object with a return code of DDS_RETCODE_OK and a value that is copied. More... | |
Result (T &&value) | |
Creates a Result object with a return code of DDS_RETCODE_OK and a value that is moved. More... | |
Result (DDS_ReturnCode_t retcode) | |
Creates a Result object with a return code and no value. More... | |
const T & | get () const &noexcept |
Gets the value without checking if the operation was successful. More... | |
T & | get () &noexcept |
Gets the value without checking if the operation was successful. More... | |
DDS_ReturnCode_t | get_return_code () const noexcept |
Gets the return code. More... | |
bool | is_ok () const noexcept |
Returns true if the operation was successful. More... | |
const T & | get_if_ok () const & |
Gets the value if the operation was successful, otherwise throws an exception. More... | |
T & | get_if_ok () & |
Gets the value if the operation was successful, otherwise throws an exception. More... | |
T && | get_if_ok () && |
Gets the value if the operation was successful, otherwise throws an exception. More... | |
void | throw_if_error () const |
Throws an exception if the operation was not successful. More... | |
A result from an operation that doesn't throw exceptions containing a return code and (if successful) a value.
For some critical operations in the API a exception-throwing and a noexcept version of the same function are provided. The noexcept versions return a Result<T> object to indicate if the operation was successful or not and, if it was, provide the return value of type T.
Note that Result<void>
is specialized to not provide a value, only a return code.
|
default |
Creates a Result object with a return code of DDS_RETCODE_ERROR and no value.
|
inlineexplicit |
Creates a Result object with a return code of DDS_RETCODE_OK and a value that is copied.
|
inlineexplicit |
Creates a Result object with a return code of DDS_RETCODE_OK and a value that is moved.
|
inlineexplicit |
Creates a Result object with a return code and no value.
|
inlinenoexcept |
Gets the value without checking if the operation was successful.
If the operation was not successful, the behavior is undefined; use is_ok() first or use get_if_ok() instead.
|
inlinenoexcept |
Gets the value without checking if the operation was successful.
If the operation was not successful, the behavior is undefined; use is_ok() first or use get_if_ok() instead.
|
inlinenoexcept |
Gets the return code.
|
inlinenoexcept |
Returns true if the operation was successful.
This is equivalent to get_return_code() == DDS_RETCODE_OK
|
inline |
Gets the value if the operation was successful, otherwise throws an exception.
References rti::core::Result< T >::throw_if_error().
|
inline |
Gets the value if the operation was successful, otherwise throws an exception.
References rti::core::Result< T >::throw_if_error().
|
inline |
Gets the value if the operation was successful, otherwise throws an exception.
References rti::core::Result< T >::throw_if_error().
|
inline |
Throws an exception if the operation was not successful.
If the operation was successful, this function does nothing.
Referenced by rti::core::Result< T >::get_if_ok().