userver: utils::OptionalRef< T > Class Template Reference
Loading...
Searching...
No Matches
utils::OptionalRef< T > Class Template Reference

#include <userver/utils/optional_ref.hpp>

Detailed Description

template<class T>
class utils::OptionalRef< T >

Class that behaves as a nullable reference. Main difference from the pointer - value comparison of pointed values.

Initializes from reference to a T or from optional<T>.

Once the reference is constructed it can not be changed to point to different address.

Definition at line 27 of file optional_ref.hpp.

Public Member Functions

constexpr OptionalRef (std::nullopt_t) noexcept
 
constexpr OptionalRef (const OptionalRef &) noexcept=default
 
constexpr OptionalRefoperator= (const OptionalRef &) noexcept=delete
 
constexpr OptionalRef (T &other) noexcept
 
constexpr OptionalRef (const T &&)=delete
 
template<typename U >
constexpr OptionalRef (const std::optional< U > &other) noexcept
 
template<typename U >
constexpr OptionalRef (std::optional< U > &other) noexcept
 
template<typename U >
constexpr OptionalRef (const std::optional< U > &&) noexcept
 
template<typename U >
constexpr OptionalRef (const boost::optional< U > &other) noexcept
 
template<typename U >
constexpr OptionalRef (boost::optional< U > &other) noexcept
 
template<typename U >
constexpr OptionalRef (const boost::optional< U > &&) noexcept
 
constexpr bool has_value () const noexcept
 
constexpr operator bool () const noexcept
 
constexpr T * operator-> () const
 
constexpr T & operator* () const
 
constexpr T & value () const
 

Constructor & Destructor Documentation

◆ OptionalRef() [1/8]

template<class T >
constexpr utils::OptionalRef< T >::OptionalRef ( std::nullopt_t )
inlineconstexprnoexcept

Definition at line 32 of file optional_ref.hpp.

◆ OptionalRef() [2/8]

template<class T >
constexpr utils::OptionalRef< T >::OptionalRef ( T & other)
inlineconstexprnoexcept

Definition at line 36 of file optional_ref.hpp.

◆ OptionalRef() [3/8]

template<class T >
template<typename U >
constexpr utils::OptionalRef< T >::OptionalRef ( const std::optional< U > & other)
inlineexplicitconstexprnoexcept

Definition at line 42 of file optional_ref.hpp.

◆ OptionalRef() [4/8]

template<class T >
template<typename U >
constexpr utils::OptionalRef< T >::OptionalRef ( std::optional< U > & other)
inlineexplicitconstexprnoexcept

Definition at line 46 of file optional_ref.hpp.

◆ OptionalRef() [5/8]

template<class T >
template<typename U >
constexpr utils::OptionalRef< T >::OptionalRef ( const std::optional< U > && )
inlineexplicitconstexprnoexcept

Definition at line 50 of file optional_ref.hpp.

◆ OptionalRef() [6/8]

template<class T >
template<typename U >
constexpr utils::OptionalRef< T >::OptionalRef ( const boost::optional< U > & other)
inlineexplicitconstexprnoexcept

Definition at line 55 of file optional_ref.hpp.

◆ OptionalRef() [7/8]

template<class T >
template<typename U >
constexpr utils::OptionalRef< T >::OptionalRef ( boost::optional< U > & other)
inlineexplicitconstexprnoexcept

Definition at line 59 of file optional_ref.hpp.

◆ OptionalRef() [8/8]

template<class T >
template<typename U >
constexpr utils::OptionalRef< T >::OptionalRef ( const boost::optional< U > && )
inlineexplicitconstexprnoexcept

Definition at line 63 of file optional_ref.hpp.

Member Function Documentation

◆ has_value()

template<class T >
constexpr bool utils::OptionalRef< T >::has_value ( ) const
inlineconstexprnoexcept

Definition at line 67 of file optional_ref.hpp.

◆ operator bool()

template<class T >
constexpr utils::OptionalRef< T >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Definition at line 68 of file optional_ref.hpp.

◆ operator*()

template<class T >
constexpr T & utils::OptionalRef< T >::operator* ( ) const
inlineconstexpr

Definition at line 75 of file optional_ref.hpp.

◆ operator->()

template<class T >
constexpr T * utils::OptionalRef< T >::operator-> ( ) const
inlineconstexpr

Definition at line 70 of file optional_ref.hpp.

◆ value()

template<class T >
constexpr T & utils::OptionalRef< T >::value ( ) const
inlineconstexpr

Definition at line 80 of file optional_ref.hpp.


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