scc 2025.09
SystemC components library
nonstd::optional< T & > Class Template Reference

#include <optional.hpp>

Inheritance diagram for nonstd::optional< T & >:
Collaboration diagram for nonstd::optional< T & >:

Public Types

using value_type = T&

Public Member Functions

template<class F>
TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then (F &&f) &
template<class F>
TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then (F &&f) &&
template<class F>
constexpr detail::invoke_result_t< F, const T & > and_then (F &&f) const &
template<class F>
constexpr detail::invoke_result_t< F, const T & > and_then (F &&f) const &&
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional & >(), std::declval< F && >())) map (F &&f) &
 Carries out some operation on the stored object if there is one.
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional && >(), std::declval< F && >())) map (F &&f) &&
template<class F>
constexpr decltype(detail::optional_map_impl(std::declval< const optional & >(), std::declval< F && >())) map (F &&f) const &
template<class F>
constexpr decltype(detail::optional_map_impl(std::declval< const optional && >(), std::declval< F && >())) map (F &&f) const &&
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional & >(), std::declval< F && >())) transform (F &&f) &
 Carries out some operation on the stored object if there is one.
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional && >(), std::declval< F && >())) transform (F &&f) &&
template<class F>
constexpr decltype(detail::optional_map_impl(std::declval< const optional & >(), std::declval< F && >())) transform (F &&f) const &
template<class F>
constexpr decltype(detail::optional_map_impl(std::declval< const optional && >(), std::declval< F && >())) transform (F &&f) const &&
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) &
 Calls f if the optional is empty.
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) &
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) &&
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) &&
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) const &
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR or_else (F &&f) const &
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) const &&
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > or_else (F &&f) const &&
template<class F, class U>
map_or (F &&f, U &&u) &
 Maps the stored value with f if there is one, otherwise returns u.
template<class F, class U>
map_or (F &&f, U &&u) &&
template<class F, class U>
map_or (F &&f, U &&u) const &
template<class F, class U>
map_or (F &&f, U &&u) const &&
template<class F, class U>
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) &
template<class F, class U>
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) &&
template<class F, class U>
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) const &
template<class F, class U>
detail::invoke_result_t< U > map_or_else (F &&f, U &&u) const &&
template<class U>
constexpr optional< typename std::decay< U >::type > conjunction (U &&u) const
 Returns u if *this has a value, otherwise an empty optional.
TL_OPTIONAL_11_CONSTEXPR optional disjunction (const optional &rhs) &
 Returns rhs if *this is empty, otherwise the current value.
constexpr optional disjunction (const optional &rhs) const &
TL_OPTIONAL_11_CONSTEXPR optional disjunction (const optional &rhs) &&
constexpr optional disjunction (const optional &rhs) const &&
TL_OPTIONAL_11_CONSTEXPR optional disjunction (optional &&rhs) &
constexpr optional disjunction (optional &&rhs) const &
TL_OPTIONAL_11_CONSTEXPR optional disjunction (optional &&rhs) &&
constexpr optional disjunction (optional &&rhs) const &&
optional take ()
 Takes the value out of the optional, leaving it empty.
constexpr optional () noexcept
 Constructs an optional that does not contain a value.
constexpr optional (nullopt_t) noexcept
TL_OPTIONAL_11_CONSTEXPR optional (const optional &rhs) noexcept=default
TL_OPTIONAL_11_CONSTEXPR optional (optional &&rhs)=default
template<class U = T, detail::enable_if_t<!detail::is_optional< detail::decay_t< U > >::value > * = nullptr>
constexpr optional (U &&u) noexcept
 Constructs the stored value with u.
template<class U>
constexpr optional (const optional< U > &rhs) noexcept
 ~optional ()=default
 No-op.
optionaloperator= (nullopt_t) noexcept
optionaloperator= (const optional &rhs)=default
template<class U = T, detail::enable_if_t<!detail::is_optional< detail::decay_t< U > >::value > * = nullptr>
optionaloperator= (U &&u)
 Rebinds this optional to u.
template<class U>
optionaloperator= (const optional< U > &rhs) noexcept
template<class U = T, detail::enable_if_t<!detail::is_optional< detail::decay_t< U > >::value > * = nullptr>
optionalemplace (U &&u) noexcept
 Rebinds this optional to u.
void swap (optional &rhs) noexcept
constexpr const T * operator-> () const noexcept
 Returns a pointer to the stored value.
TL_OPTIONAL_11_CONSTEXPR T * operator-> () noexcept
TL_OPTIONAL_11_CONSTEXPR T & operator* () noexcept
 Returns the stored value.
constexpr const T & operator* () const noexcept
constexpr bool has_value () const noexcept
constexpr operator bool () const noexcept
TL_OPTIONAL_11_CONSTEXPR T & value ()
 Returns the contained value if there is one, otherwise throws bad_optional_access.
TL_OPTIONAL_11_CONSTEXPR const T & value () const
template<class U>
constexpr T value_or (U &&u) const &noexcept
 Returns the stored value if there is one, otherwise returns u.
template<class U>
TL_OPTIONAL_11_CONSTEXPR T value_or (U &&u) &&noexcept
 \group value_or
void reset () noexcept
 Destroys the stored value if one exists, making the optional empty.

Detailed Description

template<class T>
class nonstd::optional< T & >

Specialization for when T is a reference. optional<T&> acts similarly to a T*, but provides more operations and shows intent more clearly.

Definition at line 1247 of file optional.hpp.

Member Typedef Documentation

◆ value_type

template<class T>
using nonstd::optional< T & >::value_type = T&

Definition at line 1518 of file optional.hpp.

Constructor & Destructor Documentation

◆ optional() [1/6]

template<class T>
nonstd::optional< T & >::optional ( )
inlineconstexprnoexcept

Constructs an optional that does not contain a value.

Definition at line 1521 of file optional.hpp.

◆ optional() [2/6]

template<class T>
nonstd::optional< T & >::optional ( nullopt_t )
inlineconstexprnoexcept

Definition at line 1524 of file optional.hpp.

◆ optional() [3/6]

template<class T>
TL_OPTIONAL_11_CONSTEXPR nonstd::optional< T & >::optional ( const optional< T & > & rhs)
defaultnoexcept

Copy constructor

If rhs contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.

◆ optional() [4/6]

template<class T>
TL_OPTIONAL_11_CONSTEXPR nonstd::optional< T & >::optional ( optional< T & > && rhs)
default

Move constructor

If rhs contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.

◆ optional() [5/6]

template<class T>
template<class U = T, detail::enable_if_t<!detail::is_optional< detail::decay_t< U > >::value > * = nullptr>
nonstd::optional< T & >::optional ( U && u)
inlineconstexprnoexcept

Constructs the stored value with u.

Definition at line 1541 of file optional.hpp.

◆ optional() [6/6]

template<class T>
template<class U>
nonstd::optional< T & >::optional ( const optional< U > & rhs)
inlineexplicitconstexprnoexcept

Definition at line 1547 of file optional.hpp.

Member Function Documentation

◆ and_then() [1/4]

template<class T>
template<class F>
TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > nonstd::optional< T & >::and_then ( F && f) &
inline

Carries out some operation which returns an optional on the stored object if there is one.

Definition at line 1289 of file optional.hpp.

◆ and_then() [2/4]

template<class T>
template<class F>
TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > nonstd::optional< T & >::and_then ( F && f) &&
inline

Definition at line 1296 of file optional.hpp.

◆ and_then() [3/4]

template<class T>
template<class F>
detail::invoke_result_t< F, const T & > nonstd::optional< T & >::and_then ( F && f) const &
inlineconstexpr

Definition at line 1303 of file optional.hpp.

◆ and_then() [4/4]

template<class T>
template<class F>
detail::invoke_result_t< F, const T & > nonstd::optional< T & >::and_then ( F && f) const &&
inlineconstexpr

Definition at line 1311 of file optional.hpp.

◆ conjunction()

template<class T>
template<class U>
optional< typename std::decay< U >::type > nonstd::optional< T & >::conjunction ( U && u) const
inlineconstexpr

Returns u if *this has a value, otherwise an empty optional.

Definition at line 1485 of file optional.hpp.

◆ disjunction() [1/8]

template<class T>
TL_OPTIONAL_11_CONSTEXPR optional nonstd::optional< T & >::disjunction ( const optional< T & > & rhs) &
inline

Returns rhs if *this is empty, otherwise the current value.

Definition at line 1491 of file optional.hpp.

◆ disjunction() [2/8]

template<class T>
TL_OPTIONAL_11_CONSTEXPR optional nonstd::optional< T & >::disjunction ( const optional< T & > & rhs) &&
inline

Definition at line 1495 of file optional.hpp.

◆ disjunction() [3/8]

template<class T>
optional nonstd::optional< T & >::disjunction ( const optional< T & > & rhs) const &
inlineconstexpr

Definition at line 1493 of file optional.hpp.

◆ disjunction() [4/8]

template<class T>
optional nonstd::optional< T & >::disjunction ( const optional< T & > & rhs) const &&
inlineconstexpr

Definition at line 1498 of file optional.hpp.

◆ disjunction() [5/8]

template<class T>
TL_OPTIONAL_11_CONSTEXPR optional nonstd::optional< T & >::disjunction ( optional< T & > && rhs) &
inline

Definition at line 1501 of file optional.hpp.

◆ disjunction() [6/8]

template<class T>
TL_OPTIONAL_11_CONSTEXPR optional nonstd::optional< T & >::disjunction ( optional< T & > && rhs) &&
inline

Definition at line 1505 of file optional.hpp.

◆ disjunction() [7/8]

template<class T>
optional nonstd::optional< T & >::disjunction ( optional< T & > && rhs) const &
inlineconstexpr

Definition at line 1503 of file optional.hpp.

◆ disjunction() [8/8]

template<class T>
optional nonstd::optional< T & >::disjunction ( optional< T & > && rhs) const &&
inlineconstexpr

Definition at line 1508 of file optional.hpp.

◆ emplace()

template<class T>
template<class U = T, detail::enable_if_t<!detail::is_optional< detail::decay_t< U > >::value > * = nullptr>
optional & nonstd::optional< T & >::emplace ( U && u)
inlinenoexcept

Rebinds this optional to u.

Definition at line 1585 of file optional.hpp.

◆ has_value()

template<class T>
bool nonstd::optional< T & >::has_value ( ) const
inlineconstexprnoexcept

Definition at line 1601 of file optional.hpp.

◆ map() [1/4]

template<class T>
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional & >(), std::declval< F && >())) nonstd::optional< T & >::map ( F && f) &
inline

Carries out some operation on the stored object if there is one.

Definition at line 1334 of file optional.hpp.

◆ map() [2/4]

template<class T>
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional && >(), std::declval< F && >())) nonstd::optional< T & >::map ( F && f) &&
inline

Definition at line 1339 of file optional.hpp.

◆ map() [3/4]

template<class T>
template<class F>
decltype(detail::optional_map_impl(std::declval< const optional & >(), std::declval< F && >())) nonstd::optional< T & >::map ( F && f) const &
inlineconstexpr

Definition at line 1344 of file optional.hpp.

◆ map() [4/4]

template<class T>
template<class F>
decltype(detail::optional_map_impl(std::declval< const optional && >(), std::declval< F && >())) nonstd::optional< T & >::map ( F && f) const &&
inlineconstexpr

Definition at line 1350 of file optional.hpp.

◆ map_or() [1/4]

template<class T>
template<class F, class U>
U nonstd::optional< T & >::map_or ( F && f,
U && u ) &
inline

Maps the stored value with f if there is one, otherwise returns u.

Definition at line 1446 of file optional.hpp.

◆ map_or() [2/4]

template<class T>
template<class F, class U>
U nonstd::optional< T & >::map_or ( F && f,
U && u ) &&
inline

Definition at line 1450 of file optional.hpp.

◆ map_or() [3/4]

template<class T>
template<class F, class U>
U nonstd::optional< T & >::map_or ( F && f,
U && u ) const &
inline

Definition at line 1454 of file optional.hpp.

◆ map_or() [4/4]

template<class T>
template<class F, class U>
U nonstd::optional< T & >::map_or ( F && f,
U && u ) const &&
inline

Definition at line 1459 of file optional.hpp.

◆ map_or_else() [1/4]

template<class T>
template<class F, class U>
detail::invoke_result_t< U > nonstd::optional< T & >::map_or_else ( F && f,
U && u ) &
inline

Maps the stored value with f if there is one, otherwise calls u and returns the result.

Definition at line 1466 of file optional.hpp.

◆ map_or_else() [2/4]

template<class T>
template<class F, class U>
detail::invoke_result_t< U > nonstd::optional< T & >::map_or_else ( F && f,
U && u ) &&
inline

Definition at line 1470 of file optional.hpp.

◆ map_or_else() [3/4]

template<class T>
template<class F, class U>
detail::invoke_result_t< U > nonstd::optional< T & >::map_or_else ( F && f,
U && u ) const &
inline

Definition at line 1474 of file optional.hpp.

◆ map_or_else() [4/4]

template<class T>
template<class F, class U>
detail::invoke_result_t< U > nonstd::optional< T & >::map_or_else ( F && f,
U && u ) const &&
inline

Definition at line 1479 of file optional.hpp.

◆ operator bool()

template<class T>
nonstd::optional< T & >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Definition at line 1603 of file optional.hpp.

◆ operator*() [1/2]

template<class T>
const T & nonstd::optional< T & >::operator* ( ) const
inlineconstexprnoexcept

Definition at line 1599 of file optional.hpp.

◆ operator*() [2/2]

template<class T>
TL_OPTIONAL_11_CONSTEXPR T & nonstd::optional< T & >::operator* ( )
inlinenoexcept

Returns the stored value.

Definition at line 1597 of file optional.hpp.

◆ operator->() [1/2]

template<class T>
const T * nonstd::optional< T & >::operator-> ( ) const
inlineconstexprnoexcept

Returns a pointer to the stored value.

Definition at line 1592 of file optional.hpp.

◆ operator->() [2/2]

template<class T>
TL_OPTIONAL_11_CONSTEXPR T * nonstd::optional< T & >::operator-> ( )
inlinenoexcept

Definition at line 1594 of file optional.hpp.

◆ operator=() [1/4]

template<class T>
optional & nonstd::optional< T & >::operator= ( const optional< T & > & rhs)
default

Copy assignment.

Rebinds this optional to the referee of rhs if there is one. Otherwise resets the stored value in *this.

◆ operator=() [2/4]

template<class T>
template<class U>
optional & nonstd::optional< T & >::operator= ( const optional< U > & rhs)
inlinenoexcept

Converting copy assignment operator.

Rebinds this optional to the referee of rhs if there is one. Otherwise resets the stored value in *this.

Definition at line 1578 of file optional.hpp.

◆ operator=() [3/4]

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

Assignment to empty.

Destroys the current value if there is one.

Definition at line 1556 of file optional.hpp.

◆ operator=() [4/4]

template<class T>
template<class U = T, detail::enable_if_t<!detail::is_optional< detail::decay_t< U > >::value > * = nullptr>
optional & nonstd::optional< T & >::operator= ( U && u)
inline

Rebinds this optional to u.

Definition at line 1568 of file optional.hpp.

◆ or_else() [1/8]

template<class T>
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR nonstd::optional< T & >::or_else ( F && f) &
inline

Definition at line 1403 of file optional.hpp.

◆ or_else() [2/8]

template<class T>
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR nonstd::optional< T & >::or_else ( F && f) &
inline

Calls f if the optional is empty.

Definition at line 1395 of file optional.hpp.

◆ or_else() [3/8]

template<class T>
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR nonstd::optional< T & >::or_else ( F && f) &&
inline

Definition at line 1415 of file optional.hpp.

◆ or_else() [4/8]

template<class T>
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > nonstd::optional< T & >::or_else ( F && f) &&
inline

Definition at line 1407 of file optional.hpp.

◆ or_else() [5/8]

template<class T>
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > TL_OPTIONAL_11_CONSTEXPR nonstd::optional< T & >::or_else ( F && f) const &
inline

Definition at line 1427 of file optional.hpp.

◆ or_else() [6/8]

template<class T>
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > nonstd::optional< T & >::or_else ( F && f) const &
inline

Definition at line 1419 of file optional.hpp.

◆ or_else() [7/8]

template<class T>
template<class F, detail::disable_if_ret_void< F > * = nullptr>
optional< T > nonstd::optional< T & >::or_else ( F && f) const &&
inline

Definition at line 1440 of file optional.hpp.

◆ or_else() [8/8]

template<class T>
template<class F, detail::enable_if_ret_void< F > * = nullptr>
optional< T > nonstd::optional< T & >::or_else ( F && f) const &&
inline

Definition at line 1432 of file optional.hpp.

◆ reset()

template<class T>
void nonstd::optional< T & >::reset ( )
inlinenoexcept

Destroys the stored value if one exists, making the optional empty.

Definition at line 1632 of file optional.hpp.

◆ swap()

template<class T>
void nonstd::optional< T & >::swap ( optional< T & > & rhs)
inlinenoexcept

Definition at line 1589 of file optional.hpp.

◆ take()

template<class T>
optional nonstd::optional< T & >::take ( )
inline

Takes the value out of the optional, leaving it empty.

Definition at line 1512 of file optional.hpp.

◆ transform() [1/4]

template<class T>
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional & >(), std::declval< F && >())) nonstd::optional< T & >::transform ( F && f) &
inline

Carries out some operation on the stored object if there is one.

Definition at line 1370 of file optional.hpp.

◆ transform() [2/4]

template<class T>
template<class F>
TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval< optional && >(), std::declval< F && >())) nonstd::optional< T & >::transform ( F && f) &&
inline

\group map \synopsis template <class F> auto transform(F &&f) &&;

Definition at line 1377 of file optional.hpp.

◆ transform() [3/4]

template<class T>
template<class F>
decltype(detail::optional_map_impl(std::declval< const optional & >(), std::declval< F && >())) nonstd::optional< T & >::transform ( F && f) const &
inlineconstexpr

Definition at line 1382 of file optional.hpp.

◆ transform() [4/4]

template<class T>
template<class F>
decltype(detail::optional_map_impl(std::declval< const optional && >(), std::declval< F && >())) nonstd::optional< T & >::transform ( F && f) const &&
inlineconstexpr

Definition at line 1388 of file optional.hpp.

◆ value() [1/2]

template<class T>
TL_OPTIONAL_11_CONSTEXPR T & nonstd::optional< T & >::value ( )
inline

Returns the contained value if there is one, otherwise throws bad_optional_access.

Definition at line 1606 of file optional.hpp.

◆ value() [2/2]

template<class T>
TL_OPTIONAL_11_CONSTEXPR const T & nonstd::optional< T & >::value ( ) const
inline

Definition at line 1611 of file optional.hpp.

◆ value_or() [1/2]

template<class T>
template<class U>
TL_OPTIONAL_11_CONSTEXPR T nonstd::optional< T & >::value_or ( U && u) &&
inlinenoexcept

\group value_or

Definition at line 1625 of file optional.hpp.

◆ value_or() [2/2]

template<class T>
template<class U>
T nonstd::optional< T & >::value_or ( U && u) const &
inlineconstexprnoexcept

Returns the stored value if there is one, otherwise returns u.

Definition at line 1618 of file optional.hpp.


The documentation for this class was generated from the following file:
  • /home/eyck/Projects/MINRES/SystemC-Components/src/common/nonstd/optional.hpp