libstdc++
std::optional< _Tp > Class Template Reference
Inheritance diagram for std::optional< _Tp >:
[legend]

Public Types

using value_type = _Tp
 

Public Member Functions

template<typename _Up = _Tp, _Requires< __not_self< _Up >, __not_tag< _Up >, is_constructible< _Tp, _Up >, is_convertible< _Up, _Tp > > = true>
constexpr optional (_Up &&__t) noexcept(is_nothrow_constructible_v< _Tp, _Up >)
 
template<typename _Up = _Tp, _Requires< __not_self< _Up >, __not_tag< _Up >, is_constructible< _Tp, _Up >, __not_< is_convertible< _Up, _Tp > > > = false>
constexpr optional (_Up &&__t) noexcept(is_nothrow_constructible_v< _Tp, _Up >)
 
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, const _Up & >, is_convertible< const _Up &, _Tp >, __not_< __converts_from_optional< _Tp, _Up > > > = true>
constexpr optional (const optional< _Up > &__t) noexcept(is_nothrow_constructible_v< _Tp, const _Up & >)
 
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, const _Up & >, __not_< is_convertible< const _Up &, _Tp > >, __not_< __converts_from_optional< _Tp, _Up > > > = false>
constexpr optional (const optional< _Up > &__t) noexcept(is_nothrow_constructible_v< _Tp, const _Up & >)
 
template<typename... _Args, _Requires< is_constructible< _Tp, _Args... > > = false>
constexpr optional (in_place_t, _Args &&... __args) noexcept(is_nothrow_constructible_v< _Tp, _Args... >)
 
template<typename _Up , typename... _Args, _Requires< is_constructible< _Tp, initializer_list< _Up > &, _Args... > > = false>
constexpr optional (in_place_t, initializer_list< _Up > __il, _Args &&... __args) noexcept(is_nothrow_constructible_v< _Tp, initializer_list< _Up > &, _Args... >)
 
constexpr optional (nullopt_t) noexcept
 
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, _Up >, is_convertible< _Up, _Tp >, __not_< __converts_from_optional< _Tp, _Up > > > = true>
constexpr optional (optional< _Up > &&__t) noexcept(is_nothrow_constructible_v< _Tp, _Up >)
 
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, _Up >, __not_< is_convertible< _Up, _Tp > >, __not_< __converts_from_optional< _Tp, _Up > > > = false>
constexpr optional (optional< _Up > &&__t) noexcept(is_nothrow_constructible_v< _Tp, _Up >)
 
template<typename... _Args>
constexpr enable_if_t< is_constructible_v< _Tp, _Args... >, _Tp & > emplace (_Args &&... __args) noexcept(is_nothrow_constructible_v< _Tp, _Args... >)
 
template<typename _Up , typename... _Args>
constexpr enable_if_t< is_constructible_v< _Tp, initializer_list< _Up > &, _Args... >, _Tp & > emplace (initializer_list< _Up > __il, _Args &&... __args) noexcept(is_nothrow_constructible_v< _Tp, initializer_list< _Up > &, _Args... >)
 
constexpr bool has_value () const noexcept
 
constexpr operator bool () const noexcept
 
constexpr _Tp && operator* () &&noexcept
 
constexpr _Tp & operator* () &noexcept
 
constexpr const _Tp && operator* () const &&noexcept
 
constexpr const _Tp & operator* () const &noexcept
 
constexpr const _Tp * operator-> () const noexcept
 
constexpr _Tp * operator-> () noexcept
 
template<typename _Up = _Tp>
constexpr enable_if_t< __and_v< __not_self< _Up >, __not_< __and_< is_scalar< _Tp >, is_same< _Tp, decay_t< _Up > > > >, is_constructible< _Tp, _Up >, is_assignable< _Tp &, _Up > >, optional & > operator= (_Up &&__u) noexcept(__and_v< is_nothrow_constructible< _Tp, _Up >, is_nothrow_assignable< _Tp &, _Up > >)
 
template<typename _Up >
constexpr enable_if_t< __and_v< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, const _Up & >, is_assignable< _Tp &, const _Up & >, __not_< __converts_from_optional< _Tp, _Up > >, __not_< __assigns_from_optional< _Tp, _Up > > >, optional & > operator= (const optional< _Up > &__u) noexcept(__and_v< is_nothrow_constructible< _Tp, const _Up & >, is_nothrow_assignable< _Tp &, const _Up & > >)
 
constexpr optionaloperator= (nullopt_t) noexcept
 
template<typename _Up >
constexpr enable_if_t< __and_v< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, _Up >, is_assignable< _Tp &, _Up >, __not_< __converts_from_optional< _Tp, _Up > >, __not_< __assigns_from_optional< _Tp, _Up > > >, optional & > operator= (optional< _Up > &&__u) noexcept(__and_v< is_nothrow_constructible< _Tp, _Up >, is_nothrow_assignable< _Tp &, _Up > >)
 
constexpr void reset () noexcept
 
constexpr void swap (optional &__other) noexcept(is_nothrow_move_constructible_v< _Tp > &&is_nothrow_swappable_v< _Tp >)
 
constexpr _Tp & value () &
 
constexpr _Tp && value () &&
 
constexpr const _Tp & value () const &
 
constexpr const _Tp && value () const &&
 
template<typename _Up >
constexpr _Tp value_or (_Up &&__u) &&
 
template<typename _Up >
constexpr _Tp value_or (_Up &&__u) const &
 

Detailed Description

template<typename _Tp>
class std::optional< _Tp >

Class template for optional values.

Definition at line 705 of file optional.

Member Typedef Documentation

◆ value_type

template<typename _Tp >
using std::optional< _Tp >::value_type = _Tp

Definition at line 735 of file optional.

Constructor & Destructor Documentation

◆ optional() [1/10]

template<typename _Tp >
constexpr std::optional< _Tp >::optional ( )
inlineconstexprnoexcept

Definition at line 737 of file optional.

◆ optional() [2/10]

template<typename _Tp >
constexpr std::optional< _Tp >::optional ( nullopt_t  )
inlineconstexprnoexcept

Definition at line 739 of file optional.

◆ optional() [3/10]

template<typename _Tp >
template<typename _Up = _Tp, _Requires< __not_self< _Up >, __not_tag< _Up >, is_constructible< _Tp, _Up >, is_convertible< _Up, _Tp > > = true>
constexpr std::optional< _Tp >::optional ( _Up &&  __t)
inlineconstexprnoexcept

Definition at line 747 of file optional.

◆ optional() [4/10]

template<typename _Tp >
template<typename _Up = _Tp, _Requires< __not_self< _Up >, __not_tag< _Up >, is_constructible< _Tp, _Up >, __not_< is_convertible< _Up, _Tp > > > = false>
constexpr std::optional< _Tp >::optional ( _Up &&  __t)
inlineexplicitconstexprnoexcept

Definition at line 756 of file optional.

◆ optional() [5/10]

template<typename _Tp >
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, const _Up & >, is_convertible< const _Up &, _Tp >, __not_< __converts_from_optional< _Tp, _Up > > > = true>
constexpr std::optional< _Tp >::optional ( const optional< _Up > &  __t)
inlineconstexprnoexcept

Definition at line 766 of file optional.

◆ optional() [6/10]

template<typename _Tp >
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, const _Up & >, __not_< is_convertible< const _Up &, _Tp > >, __not_< __converts_from_optional< _Tp, _Up > > > = false>
constexpr std::optional< _Tp >::optional ( const optional< _Up > &  __t)
inlineexplicitconstexprnoexcept

Definition at line 779 of file optional.

◆ optional() [7/10]

template<typename _Tp >
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, _Up >, is_convertible< _Up, _Tp >, __not_< __converts_from_optional< _Tp, _Up > > > = true>
constexpr std::optional< _Tp >::optional ( optional< _Up > &&  __t)
inlineconstexprnoexcept

Definition at line 792 of file optional.

◆ optional() [8/10]

template<typename _Tp >
template<typename _Up , _Requires< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, _Up >, __not_< is_convertible< _Up, _Tp > >, __not_< __converts_from_optional< _Tp, _Up > > > = false>
constexpr std::optional< _Tp >::optional ( optional< _Up > &&  __t)
inlineexplicitconstexprnoexcept

Definition at line 805 of file optional.

◆ optional() [9/10]

template<typename _Tp >
template<typename... _Args, _Requires< is_constructible< _Tp, _Args... > > = false>
constexpr std::optional< _Tp >::optional ( in_place_t  ,
_Args &&...  __args 
)
inlineexplicitconstexprnoexcept

Definition at line 815 of file optional.

◆ optional() [10/10]

template<typename _Tp >
template<typename _Up , typename... _Args, _Requires< is_constructible< _Tp, initializer_list< _Up > &, _Args... > > = false>
constexpr std::optional< _Tp >::optional ( in_place_t  ,
initializer_list< _Up >  __il,
_Args &&...  __args 
)
inlineexplicitconstexprnoexcept

Definition at line 824 of file optional.

Member Function Documentation

◆ emplace() [1/2]

template<typename _Tp >
template<typename... _Args>
constexpr enable_if_t< is_constructible_v< _Tp, _Args... >, _Tp & > std::optional< _Tp >::emplace ( _Args &&...  __args)
inlineconstexprnoexcept

Definition at line 914 of file optional.

◆ emplace() [2/2]

template<typename _Tp >
template<typename _Up , typename... _Args>
constexpr enable_if_t< is_constructible_v< _Tp, initializer_list< _Up > &, _Args... >, _Tp & > std::optional< _Tp >::emplace ( initializer_list< _Up >  __il,
_Args &&...  __args 
)
inlineconstexprnoexcept

Definition at line 926 of file optional.

◆ has_value()

template<typename _Tp >
constexpr bool std::optional< _Tp >::has_value ( ) const
inlineconstexprnoexcept

Definition at line 987 of file optional.

◆ operator bool()

template<typename _Tp >
constexpr std::optional< _Tp >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Definition at line 984 of file optional.

◆ operator*() [1/4]

template<typename _Tp >
constexpr _Tp && std::optional< _Tp >::operator* ( ) &&
inlineconstexprnoexcept

Definition at line 977 of file optional.

◆ operator*() [2/4]

template<typename _Tp >
constexpr _Tp & std::optional< _Tp >::operator* ( ) &
inlineconstexprnoexcept

Definition at line 973 of file optional.

◆ operator*() [3/4]

template<typename _Tp >
constexpr const _Tp && std::optional< _Tp >::operator* ( ) const &&
inlineconstexprnoexcept

Definition at line 981 of file optional.

◆ operator*() [4/4]

template<typename _Tp >
constexpr const _Tp & std::optional< _Tp >::operator* ( ) const &
inlineconstexprnoexcept

Definition at line 969 of file optional.

◆ operator->() [1/2]

template<typename _Tp >
constexpr const _Tp * std::optional< _Tp >::operator-> ( ) const
inlineconstexprnoexcept

Definition at line 961 of file optional.

◆ operator->() [2/2]

template<typename _Tp >
constexpr _Tp * std::optional< _Tp >::operator-> ( )
inlineconstexprnoexcept

Definition at line 965 of file optional.

◆ operator=() [1/4]

template<typename _Tp >
template<typename _Up = _Tp>
constexpr enable_if_t< __and_v< __not_self< _Up >, __not_< __and_< is_scalar< _Tp >, is_same< _Tp, decay_t< _Up > > > >, is_constructible< _Tp, _Up >, is_assignable< _Tp &, _Up > >, optional & > std::optional< _Tp >::operator= ( _Up &&  __u)
inlineconstexprnoexcept

Definition at line 846 of file optional.

◆ operator=() [2/4]

template<typename _Tp >
template<typename _Up >
constexpr enable_if_t< __and_v< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, const _Up & >, is_assignable< _Tp &, const _Up & >, __not_< __converts_from_optional< _Tp, _Up > >, __not_< __assigns_from_optional< _Tp, _Up > > >, optional & > std::optional< _Tp >::operator= ( const optional< _Up > &  __u)
inlineconstexprnoexcept

Definition at line 866 of file optional.

◆ operator=() [3/4]

template<typename _Tp >
constexpr optional & std::optional< _Tp >::operator= ( nullopt_t  )
inlineconstexprnoexcept

Definition at line 832 of file optional.

◆ operator=() [4/4]

template<typename _Tp >
template<typename _Up >
constexpr enable_if_t< __and_v< __not_< is_same< _Tp, _Up > >, is_constructible< _Tp, _Up >, is_assignable< _Tp &, _Up >, __not_< __converts_from_optional< _Tp, _Up > >, __not_< __assigns_from_optional< _Tp, _Up > > >, optional & > std::optional< _Tp >::operator= ( optional< _Up > &&  __u)
inlineconstexprnoexcept

Definition at line 892 of file optional.

◆ reset()

template<typename _Tp >
constexpr void std::optional< _Tp >::reset ( )
inlineconstexprnoexcept

Definition at line 1170 of file optional.

◆ swap()

template<typename _Tp >
constexpr void std::optional< _Tp >::swap ( optional< _Tp > &  __other)
inlineconstexprnoexcept

Definition at line 939 of file optional.

◆ value() [1/4]

template<typename _Tp >
constexpr _Tp & std::optional< _Tp >::value ( ) &
inlineconstexpr

Definition at line 999 of file optional.

◆ value() [2/4]

template<typename _Tp >
constexpr _Tp && std::optional< _Tp >::value ( ) &&
inlineconstexpr

Definition at line 1007 of file optional.

◆ value() [3/4]

template<typename _Tp >
constexpr const _Tp & std::optional< _Tp >::value ( ) const &
inlineconstexpr

Definition at line 991 of file optional.

◆ value() [4/4]

template<typename _Tp >
constexpr const _Tp && std::optional< _Tp >::value ( ) const &&
inlineconstexpr

Definition at line 1015 of file optional.

◆ value_or() [1/2]

template<typename _Tp >
template<typename _Up >
constexpr _Tp std::optional< _Tp >::value_or ( _Up &&  __u) &&
inlineconstexpr

Definition at line 1037 of file optional.

◆ value_or() [2/2]

template<typename _Tp >
template<typename _Up >
constexpr _Tp std::optional< _Tp >::value_or ( _Up &&  __u) const &
inlineconstexpr

Definition at line 1024 of file optional.

Friends And Related Symbol Documentation

◆ optional

template<typename _Tp >
template<typename _Up >
friend class optional
friend

Definition at line 1174 of file optional.


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