Manpages - std_optional.3

Table of Contents

NAME

std::optional< _Tp > - Class template for optional values.

SYNOPSIS


Inherits std::_Optional_base< _Tp, bool, bool >, and std::_Enable_copy_move< is_copy_constructible_v< _Tp >, __and_v< is_copy_constructible< _Tp >, is_copy_assignable< _Tp > >, is_move_constructible_v< _Tp >, __and_v< is_move_constructible< _Tp >, is_move_assignable< _Tp > >, optional< _Tp > >.

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> enable_if_t*< is_constructible_v< _Tp, _Args… >, _Tp & > *emplace (_Args &&… __args) noexcept(is_nothrow_constructible_v< _Tp, _Args… >)

template<typename _Up , typename… _Args> 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> 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 > enable_if_t*< __and_v< __not_< *is_same*< _Tp, _Up > >, *is_constructible*< _Tp, const _Up & >, *is_assignable*< _Tp &, _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 & > >)

optional & operator= (nullopt_t) noexcept

template<typename _Up > 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 > >)

void reset () noexcept

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 663 of file std/optional.

Member Typedef Documentation

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

_Tp Definition at line 693 of file std/optional.

Constructor & Destructor Documentation

template<typename _Tp > constexpr std::optional*< _Tp >::*optional

()= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 695 of file std/optional.

template<typename _Tp > constexpr std::optional*< _Tp >::*optional

(nullopt_t)= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 697 of file std/optional.

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)= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 705 of file std/optional.

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)= [inline]=, = [explicit]=, = [constexpr]=, = [noexcept]= Definition at line 714 of file std/optional.

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)= [inline]=, = [constexpr]=, = [noexcept]= Definition at line *724 of file std/optional.

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)= [inline]=, = [explicit]=, = [constexpr]=, = [noexcept]= Definition at line *737 of file std/optional.

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)= [inline]=, = [constexpr]=, = [noexcept]= Definition at line *750 of file std/optional.

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)= [inline]=, = [explicit]=, = [constexpr]=, = [noexcept]= Definition at line *763 of file std/optional.

template<typename _Tp > template<typename… _Args, _Requires<

is_constructible*< _Tp, _Args… > > = false> constexpr *std::optional*< _Tp >::*optional (in_place_t, _Args &&… __args)= [inline]=, = [explicit]=, = [constexpr]=, = [noexcept]= Definition at line 773 of file std/optional.

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)= [inline]=, = [explicit]=, = [constexpr]=, = [noexcept]= Definition at line *782 of file std/optional.

Member Function Documentation

template<typename _Tp > template<typename… _Args> *enable_if_t*<

is_constructible_v< _Tp, _Args… >, _Tp & > std::optional*< _Tp >::emplace (_Args &&… __args)= [inline]=, = [noexcept]= Definition at line *868 of file std/optional.

template<typename _Tp > template<typename _Up , typename… _Args>

enable_if_t*< is_constructible_v< _Tp, *initializer_list*< _Up > &, _Args… >, _Tp & > *std::optional*< _Tp >::emplace (*initializer_list*< _Up > __il, _Args &&… __args)= [inline]=, = [noexcept]= Definition at line *879 of file std/optional.

template<typename _Tp > constexpr bool *std::optional*< _Tp

>::has_value () const= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 940 of file std/optional.

template<typename _Tp > constexpr *std::optional*< _Tp >::operator

bool () const= [inline]=, = [explicit]=, = [constexpr]=, = [noexcept]= Definition at line 937 of file std/optional.

template<typename _Tp > constexpr _Tp && *std::optional*< _Tp

>::operator* () &&= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 930 of file std/optional.

template<typename _Tp > constexpr _Tp & *std::optional*< _Tp

>::operator* () &= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 926 of file std/optional.

template<typename _Tp > constexpr const _Tp && *std::optional*< _Tp

>::operator* () const &&= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 934 of file std/optional.

template<typename _Tp > constexpr const _Tp & *std::optional*< _Tp

>::operator* () const &= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 922 of file std/optional.

template<typename _Tp > constexpr const _Tp * *std::optional*< _Tp

>::operator-> () const= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 914 of file std/optional.

template<typename _Tp > constexpr _Tp * *std::optional*< _Tp

>::operator-> ()= [inline]=, = [constexpr]=, = [noexcept]= Definition at line 918 of file std/optional.

template<typename _Tp > template<typename _Up = _Tp> *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)= [inline]=, = [noexcept]= Definition at line *803 of file std/optional.

template<typename _Tp > template<typename _Up > *enable_if_t*<

__and_v< __not_< is_same*< _Tp, _Up > >, *is_constructible*< _Tp, const _Up & >, *is_assignable*< _Tp &, _Up >, __not_< __converts_from_optional< _Tp, _Up > >, __not_< __assigns_from_optional< _Tp, _Up > > >, *optional & > std::optional*< _Tp >::operator= (const *optional*< _Up > & __u)= [inline]=, = [noexcept]= Definition at line *822 of file std/optional.

template<typename _Tp > optional & *std::optional*< _Tp

>::operator= (nullopt_t)= [inline]=, = [noexcept]= Definition at line 790 of file std/optional.

template<typename _Tp > template<typename _Up > *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)= [inline]=, = [noexcept]= Definition at line *847 of file std/optional.

template<typename _Tp > void *std::optional*< _Tp >::reset

()= [inline]=, = [noexcept]= Definition at line 998 of file std/optional.

template<typename _Tp > void *std::optional*< _Tp >::swap

(optional*< _Tp > & __other)= [inline]=, = [noexcept]= Definition at line *892 of file std/optional.

template<typename _Tp > constexpr _Tp & *std::optional*< _Tp >::value

() &= [inline]=, = [constexpr]= Definition at line 952 of file std/optional.

template<typename _Tp > constexpr _Tp && *std::optional*< _Tp

>::value () &&= [inline]=, = [constexpr]= Definition at line 960 of file std/optional.

template<typename _Tp > constexpr const _Tp & *std::optional*< _Tp

>::value () const &= [inline]=, = [constexpr]= Definition at line 944 of file std/optional.

template<typename _Tp > constexpr const _Tp && *std::optional*< _Tp

>::value () const &&= [inline]=, = [constexpr]= Definition at line 968 of file std/optional.

template<typename _Tp > template<typename _Up > constexpr _Tp

std::optional*< _Tp >::value_or (_Up && __u) &&= [inline]=, = [constexpr]= Definition at line *988 of file std/optional.

template<typename _Tp > template<typename _Up > constexpr _Tp

std::optional*< _Tp >::value_or (_Up && __u) const &= [inline]=, = [constexpr]= Definition at line *977 of file std/optional.

Author

Generated automatically by Doxygen for libstdc++ from the source code.

Author: dt

Created: 2022-02-20 Sun 19:43