libstdc++
Optional values
Collaboration diagram for Optional values:

Classes

struct  std::experimental::fundamentals_v1::_Has_addressof< _Tp >
 
class  std::experimental::fundamentals_v1::_Optional_base< _Tp, _ShouldProvideDestructor >
 
class  std::experimental::fundamentals_v1::_Optional_base< _Tp, false >
 
class  std::experimental::fundamentals_v1::bad_optional_access
 
struct  std::experimental::fundamentals_v1::in_place_t
 
struct  std::experimental::fundamentals_v1::nullopt_t
 
class  std::experimental::fundamentals_v1::optional< _Tp >
 

Macros

#define __cpp_lib_experimental_optional
 

Typedefs

template<typename _Tp , typename _Up >
using std::experimental::__assigns_from_optional = __or_< is_assignable< _Tp &, const optional< _Up > & >, is_assignable< _Tp &, optional< _Up > & >, is_assignable< _Tp &, const optional< _Up > && >, is_assignable< _Tp &, optional< _Up > && > >
 
template<typename _Tp , typename _Up >
using std::experimental::__converts_from_optional = __or_< is_constructible< _Tp, const optional< _Up > & >, is_constructible< _Tp, optional< _Up > & >, is_constructible< _Tp, const optional< _Up > && >, is_constructible< _Tp, optional< _Up > && >, is_convertible< const optional< _Up > &, _Tp >, is_convertible< optional< _Up > &, _Tp >, is_convertible< const optional< _Up > &&, _Tp >, is_convertible< optional< _Up > &&, _Tp > >
 

Functions

template<typename _Tp >
constexpr enable_if_t<!_Has_addressof< _Tp >::value, _Tp * > std::experimental::__constexpr_addressof (_Tp &__t)
 
void std::experimental::__throw_bad_optional_access (const char *) __attribute__((__noreturn__))
 
template<typename _Tp >
constexpr optional< decay_t< _Tp > > std::experimental::make_optional (_Tp &&__t)
 
template<typename _Tp >
constexpr bool std::experimental::operator!= (const _Tp &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator!= (const optional< _Tp > &__lhs, _Tp const &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator!= (const optional< _Tp > &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator!= (const optional< _Tp > &__lhs, nullopt_t) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator!= (nullopt_t, const optional< _Tp > &__rhs) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator< (const _Tp &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator< (const optional< _Tp > &, nullopt_t) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator< (const optional< _Tp > &__lhs, const _Tp &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator< (const optional< _Tp > &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator< (nullopt_t, const optional< _Tp > &__rhs) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator<= (const _Tp &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator<= (const optional< _Tp > &__lhs, const _Tp &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator<= (const optional< _Tp > &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator<= (const optional< _Tp > &__lhs, nullopt_t) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator<= (nullopt_t, const optional< _Tp > &) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator== (const _Tp &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator== (const optional< _Tp > &__lhs, const _Tp &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator== (const optional< _Tp > &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator== (const optional< _Tp > &__lhs, nullopt_t) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator== (nullopt_t, const optional< _Tp > &__rhs) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator> (const _Tp &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator> (const optional< _Tp > &__lhs, const _Tp &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator> (const optional< _Tp > &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator> (const optional< _Tp > &__lhs, nullopt_t) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator> (nullopt_t, const optional< _Tp > &) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator>= (const _Tp &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator>= (const optional< _Tp > &, nullopt_t) noexcept
 
template<typename _Tp >
constexpr bool std::experimental::operator>= (const optional< _Tp > &__lhs, const _Tp &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator>= (const optional< _Tp > &__lhs, const optional< _Tp > &__rhs)
 
template<typename _Tp >
constexpr bool std::experimental::operator>= (nullopt_t, const optional< _Tp > &__rhs) noexcept
 
template<typename _Tp >
void std::experimental::swap (optional< _Tp > &__lhs, optional< _Tp > &__rhs) noexcept(noexcept(__lhs.swap(__rhs)))
 

Variables

constexpr in_place_t std::experimental::in_place
 
constexpr nullopt_t std::experimental::nullopt
 

Detailed Description

Class template for optional values and surrounding facilities, as described in n3793 "A proposal to add a utility class to represent optional objects (Revision 5)".

Macro Definition Documentation

◆ __cpp_lib_experimental_optional

#define __cpp_lib_experimental_optional

Definition at line 75 of file optional.

Typedef Documentation

◆ __assigns_from_optional

template<typename _Tp , typename _Up >
using std::experimental::fundamentals_v1::__assigns_from_optional = typedef __or_<is_assignable<_Tp&, const optional<_Up>&>, is_assignable<_Tp&, optional<_Up>&>, is_assignable<_Tp&, const optional<_Up>&&>, is_assignable<_Tp&, optional<_Up>&&> >

Definition at line 481 of file optional.

◆ __converts_from_optional

template<typename _Tp , typename _Up >
using std::experimental::fundamentals_v1::__converts_from_optional = typedef __or_<is_constructible<_Tp, const optional<_Up>&>, is_constructible<_Tp, optional<_Up>&>, is_constructible<_Tp, const optional<_Up>&&>, is_constructible<_Tp, optional<_Up>&&>, is_convertible<const optional<_Up>&, _Tp>, is_convertible<optional<_Up>&, _Tp>, is_convertible<const optional<_Up>&&, _Tp>, is_convertible<optional<_Up>&&, _Tp> >

Definition at line 470 of file optional.

Function Documentation

◆ __constexpr_addressof()

template<typename _Tp >
constexpr enable_if_t<!_Has_addressof< _Tp >::value, _Tp * > std::experimental::fundamentals_v1::__constexpr_addressof ( _Tp &  __t)
constexpr

An overload that attempts to take the address of an lvalue as a constant expression. Falls back to __addressof in the presence of an overloaded addressof operator (unary operator&), in which case the call will not be a constant expression.

Definition at line 175 of file optional.

◆ __throw_bad_optional_access()

void std::experimental::fundamentals_v1::__throw_bad_optional_access ( const char *  __s)
inline

Definition at line 132 of file optional.

◆ make_optional()

template<typename _Tp >
constexpr optional< decay_t< _Tp > > std::experimental::fundamentals_v1::make_optional ( _Tp &&  __t)
constexpr

Definition at line 977 of file optional.

◆ operator!=() [1/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator!= ( const _Tp &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 925 of file optional.

◆ operator!=() [2/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator!= ( const optional< _Tp > &  __lhs,
_Tp const &  __rhs 
)
constexpr

Definition at line 920 of file optional.

◆ operator!=() [3/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator!= ( const optional< _Tp > &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 821 of file optional.

◆ operator!=() [4/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator!= ( const optional< _Tp > &  __lhs,
nullopt_t   
)
constexprnoexcept

Definition at line 859 of file optional.

◆ operator!=() [5/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator!= ( nullopt_t  ,
const optional< _Tp > &  __rhs 
)
constexprnoexcept

Definition at line 864 of file optional.

◆ operator<() [1/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator< ( const _Tp &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 934 of file optional.

◆ operator<() [2/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator< ( const optional< _Tp > &  ,
nullopt_t   
)
constexprnoexcept

Definition at line 868 of file optional.

◆ operator<() [3/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator< ( const optional< _Tp > &  __lhs,
const _Tp &  __rhs 
)
constexpr

Definition at line 929 of file optional.

◆ operator<() [4/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator< ( const optional< _Tp > &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 825 of file optional.

◆ operator<() [5/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator< ( nullopt_t  ,
const optional< _Tp > &  __rhs 
)
constexprnoexcept

Definition at line 873 of file optional.

◆ operator<=() [1/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator<= ( const _Tp &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 954 of file optional.

◆ operator<=() [2/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator<= ( const optional< _Tp > &  __lhs,
const _Tp &  __rhs 
)
constexpr

Definition at line 949 of file optional.

◆ operator<=() [3/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator<= ( const optional< _Tp > &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 837 of file optional.

◆ operator<=() [4/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator<= ( const optional< _Tp > &  __lhs,
nullopt_t   
)
constexprnoexcept

Definition at line 888 of file optional.

◆ operator<=() [5/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator<= ( nullopt_t  ,
const optional< _Tp > &   
)
constexprnoexcept

Definition at line 893 of file optional.

◆ operator==() [1/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator== ( const _Tp &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 915 of file optional.

◆ operator==() [2/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator== ( const optional< _Tp > &  __lhs,
const _Tp &  __rhs 
)
constexpr

Definition at line 910 of file optional.

◆ operator==() [3/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator== ( const optional< _Tp > &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 813 of file optional.

◆ operator==() [4/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator== ( const optional< _Tp > &  __lhs,
nullopt_t   
)
constexprnoexcept

Definition at line 849 of file optional.

◆ operator==() [5/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator== ( nullopt_t  ,
const optional< _Tp > &  __rhs 
)
constexprnoexcept

Definition at line 854 of file optional.

◆ operator>() [1/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator> ( const _Tp &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 945 of file optional.

◆ operator>() [2/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator> ( const optional< _Tp > &  __lhs,
const _Tp &  __rhs 
)
constexpr

Definition at line 940 of file optional.

◆ operator>() [3/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator> ( const optional< _Tp > &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 833 of file optional.

◆ operator>() [4/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator> ( const optional< _Tp > &  __lhs,
nullopt_t   
)
constexprnoexcept

Definition at line 879 of file optional.

◆ operator>() [5/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator> ( nullopt_t  ,
const optional< _Tp > &   
)
constexprnoexcept

Definition at line 884 of file optional.

◆ operator>=() [1/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator>= ( const _Tp &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 965 of file optional.

◆ operator>=() [2/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator>= ( const optional< _Tp > &  ,
nullopt_t   
)
constexprnoexcept

Definition at line 899 of file optional.

◆ operator>=() [3/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator>= ( const optional< _Tp > &  __lhs,
const _Tp &  __rhs 
)
constexpr

Definition at line 960 of file optional.

◆ operator>=() [4/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator>= ( const optional< _Tp > &  __lhs,
const optional< _Tp > &  __rhs 
)
constexpr

Definition at line 843 of file optional.

◆ operator>=() [5/5]

template<typename _Tp >
constexpr bool std::experimental::fundamentals_v1::operator>= ( nullopt_t  ,
const optional< _Tp > &  __rhs 
)
constexprnoexcept

Definition at line 904 of file optional.

◆ swap()

template<typename _Tp >
void std::experimental::fundamentals_v1::swap ( optional< _Tp > &  __lhs,
optional< _Tp > &  __rhs 
)
inlinenoexcept

Definition at line 971 of file optional.

Variable Documentation

◆ in_place

constexpr in_place_t std::experimental::fundamentals_v1::in_place
constexpr

Tag for in-place construction.

Definition at line 88 of file optional.

◆ nullopt

constexpr nullopt_t std::experimental::fundamentals_v1::nullopt
constexpr

Tag to disengage optional objects.

Definition at line 107 of file optional.