Fast CDR  Version 2.2.2
Fast CDR
Loading...
Searching...
No Matches
optional< T > Class Template Reference

This class template manages an optional contained value, i.e. More...

#include <optional.hpp>

Public Types

using type = T
 

Public Member Functions

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

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.

Member Typedef Documentation

◆ type

template<class T >
using type = T

Constructor & Destructor Documentation

◆ optional() [1/5]

template<class T >
optional ( )
default

Default constructor.

◆ optional() [2/5]

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

Copy constructor from an instance of the templated class.

◆ optional() [3/5]

template<class T >
optional ( T &&  val)
inlinenoexcept

Move constructor from an instance of the templated class.

◆ optional() [4/5]

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

Copy constructor.

◆ optional() [5/5]

template<class T >
optional ( optional< T > &&  val)
inlinenoexcept

Move constructor.

◆ ~optional()

template<class T >
~optional ( )
default

Destructor.

Member Function Documentation

◆ emplace()

template<class T >
template<class ... Args>
void emplace ( Args &&...  _args)
inline

Constructs the contained value in-place.

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

◆ has_value()

template<class T >
bool has_value ( ) const
inline

Checks whether the optional contains a value.

Returns
Whether the optional contains a value.

◆ operator bool()

template<class T >
operator bool ( ) const
inlineexplicitnoexcept

Checks whether the optional contains a value.

◆ operator!=()

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

Compares optional values.

◆ operator*() [1/4]

template<class T >
T && operator* ( ) &&
inlinenoexcept

Accesses the contained value.

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

Returns
The contained value.

◆ operator*() [2/4]

template<class T >
T & operator* ( ) &
inlinenoexcept

Accesses the contained value.

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

Returns
The contained value.

◆ operator*() [3/4]

template<class T >
const T && operator* ( ) const &&
inlinenoexcept

Accesses the contained value.

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

Returns
The contained value.

◆ operator*() [4/4]

template<class T >
const T & operator* ( ) const &
inlinenoexcept

Accesses the contained value.

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

Returns
The contained value.

◆ operator->() [1/2]

template<class T >
const T * operator-> ( ) const
inlinenoexcept

Accesses the contained value.

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

Returns
The contained value.

◆ operator->() [2/2]

template<class T >
T * operator-> ( )
inlinenoexcept

Accesses the contained value.

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

Returns
The contained value.

◆ operator=() [1/5]

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

Assigns content from an optional.

◆ operator=() [2/5]

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

Assigns content from an instance of the templated class.

◆ operator=() [3/5]

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

Uninitialized the optional.

◆ operator=() [4/5]

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

Assigns content from an optional.

◆ operator=() [5/5]

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

Assigns content from an instance of the templated class.

◆ operator==()

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

Compares optional values.

◆ reset()

template<class T >
void 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.

◆ value() [1/4]

template<class T >
T & value ( ) &
inline

Returns the contained value.

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

◆ value() [2/4]

template<class T >
T && value ( ) &&
inline

Returns the contained value.

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

◆ value() [3/4]

template<class T >
const T & value ( ) const &
inline

Returns the contained value.

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

◆ value() [4/4]

template<class T >
const T && value ( ) const &&
inline

Returns the contained value.

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

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