Public Types | Public Member Functions | Private Attributes | List of all members
eprosima::fastcdr::optional< T > Class Template Reference

This class template manages an optional contained value, i.e. a value that may or may not be present. More...

#include <optional.hpp>

Public Types

using type = T
 

Public Member Functions

template<class ... Args>
void emplace (Args &&... _args)
 Constructs the contained value in-place. More...
 
bool has_value () const
 Checks whether the optional contains a value. More...
 
 operator bool () const noexcept
 Checks whether the optional contains a value. More...
 
bool operator!= (const optional &opt_val) const
 Compares optional values. More...
 
T && operator* () &&noexcept
 Accesses the contained value. More...
 
T & operator* () &noexcept
 Accesses the contained value. More...
 
const T && operator* () const &&noexcept
 Accesses the contained value. More...
 
const T & operator* () const &noexcept
 Accesses the contained value. More...
 
const T * operator-> () const noexcept
 Accesses the contained value. More...
 
T * operator-> () noexcept
 Accesses the contained value. More...
 
optionaloperator= (const optional &opt)
 Assigns content from an optional. More...
 
optionaloperator= (const T &val)
 Assigns content from an instance of the templated class. More...
 
optionaloperator= (nullopt_t) noexcept
 Uninitialized the optional. More...
 
optionaloperator= (optional &&opt)
 Assigns content from an optional. More...
 
optionaloperator= (T &&val)
 Assigns content from an instance of the templated class. More...
 
bool operator== (const optional &opt_val) const
 Compares optional values. More...
 
 optional ()=default
 Default constructor. More...
 
 optional (const optional< T > &val) noexcept
 Copy constructor. More...
 
 optional (const T &val) noexcept
 Copy constructor from an instance of the templated class. More...
 
 optional (optional< T > &&val) noexcept
 Move constructor. More...
 
 optional (T &&val) noexcept
 Move constructor from an instance of the templated class. More...
 
void reset (bool initial_engaged=false)
 Reset the state of the optional. More...
 
T & value () &
 Returns the contained value. More...
 
T && value () &&
 Returns the contained value. More...
 
const T & value () const &
 Returns the contained value. More...
 
const T && value () const &&
 Returns the contained value. More...
 
 ~optional ()=default
 Destructor. More...
 

Private Attributes

detail::optional_storage< T > storage_
 

Detailed Description

template<class T>
class eprosima::fastcdr::optional< T >

This class template manages an optional contained value, i.e. a value that may or may not be present.

Definition at line 46 of file optional.hpp.

Member Typedef Documentation

◆ type

template<class T >
using eprosima::fastcdr::optional< T >::type = T

Definition at line 50 of file optional.hpp.

Constructor & Destructor Documentation

◆ optional() [1/5]

template<class T >
eprosima::fastcdr::optional< T >::optional ( )
default

Default constructor.

◆ optional() [2/5]

template<class T >
eprosima::fastcdr::optional< T >::optional ( const T &  val)
inlinenoexcept

Copy constructor from an instance of the templated class.

Definition at line 56 of file optional.hpp.

◆ optional() [3/5]

template<class T >
eprosima::fastcdr::optional< T >::optional ( T &&  val)
inlinenoexcept

Move constructor from an instance of the templated class.

Definition at line 64 of file optional.hpp.

◆ optional() [4/5]

template<class T >
eprosima::fastcdr::optional< T >::optional ( const optional< T > &  val)
inlinenoexcept

Copy constructor.

Definition at line 72 of file optional.hpp.

◆ optional() [5/5]

template<class T >
eprosima::fastcdr::optional< T >::optional ( optional< T > &&  val)
inlinenoexcept

Move constructor.

Definition at line 80 of file optional.hpp.

◆ ~optional()

template<class T >
eprosima::fastcdr::optional< T >::~optional ( )
default

Destructor.

Member Function Documentation

◆ emplace()

template<class T >
template<class ... Args>
void eprosima::fastcdr::optional< T >::emplace ( Args &&...  _args)
inline

Constructs the contained value in-place.

Parameters
[in]_argsThe arguments to pass to the constructor.

Definition at line 95 of file optional.hpp.

◆ has_value()

template<class T >
bool eprosima::fastcdr::optional< T >::has_value ( ) const
inline

Checks whether the optional contains a value.

Returns
Whether the optional contains a value.

Definition at line 196 of file optional.hpp.

◆ operator bool()

template<class T >
eprosima::fastcdr::optional< T >::operator bool ( ) const
inlineexplicitnoexcept

Checks whether the optional contains a value.

Definition at line 343 of file optional.hpp.

◆ operator!=()

template<class T >
bool eprosima::fastcdr::optional< T >::operator!= ( const optional< T > &  opt_val) const
inline

Compares optional values.

Definition at line 264 of file optional.hpp.

◆ operator*() [1/4]

template<class T >
T&& eprosima::fastcdr::optional< T >::operator* ( ) &&
inlinenoexcept

Accesses the contained value.

The behavior is undefined if *this does not contain a value.

Returns
The contained value.

Definition at line 301 of file optional.hpp.

◆ operator*() [2/4]

template<class T >
T& eprosima::fastcdr::optional< T >::operator* ( ) &
inlinenoexcept

Accesses the contained value.

The behavior is undefined if *this does not contain a value.

Returns
The contained value.

Definition at line 277 of file optional.hpp.

◆ operator*() [3/4]

template<class T >
const T&& eprosima::fastcdr::optional< T >::operator* ( ) const &&
inlinenoexcept

Accesses the contained value.

The behavior is undefined if *this does not contain a value.

Returns
The contained value.

Definition at line 313 of file optional.hpp.

◆ operator*() [4/4]

template<class T >
const T& eprosima::fastcdr::optional< T >::operator* ( ) const &
inlinenoexcept

Accesses the contained value.

The behavior is undefined if *this does not contain a value.

Returns
The contained value.

Definition at line 289 of file optional.hpp.

◆ operator->() [1/2]

template<class T >
const T* eprosima::fastcdr::optional< T >::operator-> ( ) const
inlinenoexcept

Accesses the contained value.

The behavior is undefined if *this does not contain a value.

Returns
The contained value.

Definition at line 337 of file optional.hpp.

◆ operator->() [2/2]

template<class T >
T* eprosima::fastcdr::optional< T >::operator-> ( )
inlinenoexcept

Accesses the contained value.

The behavior is undefined if *this does not contain a value.

Returns
The contained value.

Definition at line 325 of file optional.hpp.

◆ operator=() [1/5]

template<class T >
optional& eprosima::fastcdr::optional< T >::operator= ( const optional< T > &  opt)
inline

Assigns content from an optional.

Definition at line 202 of file optional.hpp.

◆ operator=() [2/5]

template<class T >
optional& eprosima::fastcdr::optional< T >::operator= ( const T &  val)
inline

Assigns content from an instance of the templated class.

Definition at line 228 of file optional.hpp.

◆ operator=() [3/5]

template<class T >
optional& eprosima::fastcdr::optional< T >::operator= ( nullopt_t  )
inlinenoexcept

Uninitialized the optional.

Definition at line 248 of file optional.hpp.

◆ operator=() [4/5]

template<class T >
optional& eprosima::fastcdr::optional< T >::operator= ( optional< T > &&  opt)
inline

Assigns content from an optional.

Definition at line 215 of file optional.hpp.

◆ operator=() [5/5]

template<class T >
optional& eprosima::fastcdr::optional< T >::operator= ( T &&  val)
inline

Assigns content from an instance of the templated class.

Definition at line 238 of file optional.hpp.

◆ operator==()

template<class T >
bool eprosima::fastcdr::optional< T >::operator== ( const optional< T > &  opt_val) const
inline

Compares optional values.

Definition at line 256 of file optional.hpp.

◆ reset()

template<class T >
void eprosima::fastcdr::optional< T >::reset ( bool  initial_engaged = false)
inline

Reset the state of the optional.

Parameters
[in]initial_engagedTrue value initializes the state with a default instance of the templated class. False value leaves the optional in a uninitialized state.

Definition at line 109 of file optional.hpp.

◆ value() [1/4]

template<class T >
T& eprosima::fastcdr::optional< T >::value ( ) &
inline

Returns the contained value.

Returns
The contained value.
Exceptions
exception::BadOptionalAccessExceptionThis exception is thrown when the optional is uninitialized.

Definition at line 129 of file optional.hpp.

◆ value() [2/4]

template<class T >
T&& eprosima::fastcdr::optional< T >::value ( ) &&
inline

Returns the contained value.

Returns
The contained value.
Exceptions
exception::BadOptionalAccessExceptionThis exception is thrown when the optional is uninitialized.

Definition at line 163 of file optional.hpp.

◆ value() [3/4]

template<class T >
const T& eprosima::fastcdr::optional< T >::value ( ) const &
inline

Returns the contained value.

Returns
The contained value.
Exceptions
exception::BadOptionalAccessExceptionThis exception is thrown when the optional is uninitialized.

Definition at line 146 of file optional.hpp.

◆ value() [4/4]

template<class T >
const T&& eprosima::fastcdr::optional< T >::value ( ) const &&
inline

Returns the contained value.

Returns
The contained value.
Exceptions
exception::BadOptionalAccessExceptionThis exception is thrown when the optional is uninitialized.

Definition at line 180 of file optional.hpp.

Member Data Documentation

◆ storage_

template<class T >
detail::optional_storage<T> eprosima::fastcdr::optional< T >::storage_
private

Definition at line 350 of file optional.hpp.


The documentation for this class was generated from the following file:


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:52