STD::OPTIONAL(3cxx)
πΈ NAME πΈ
okay so welcome to std::optional< _Tp > bestie β it's a class template for optional values. π And yes, this is the std::optional< _Tp >(3cxx) page, we're here, we're doing it, let's go. π¦
β¨ SYNOPSIS β¨
#include <optional>
Also important: it inherits std::_Optional_base< _Tp, bool, bool >. Family tree matters, periodt. π
π Public Types
using value_typeβ that's it, that's the type. iconic.
π Public Member Functions
okay this is the long part, grab a snack π β every single one, no skipping:
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 = _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, _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 _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... _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) noexcepttemplate<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 _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... _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 noexceptconstexpr operator bool () const noexceptconstexpr _Tp && operator* () &&noexceptconstexpr _Tp & operator* () &noexceptconstexpr const _Tp && operator* () const &&noexceptconstexpr const _Tp & operator* () const &noexceptconstexpr const _Tp * operator-> () const noexceptconstexpr _Tp * operator-> () noexcepttemplate<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 optional & operator= (nullopt_t) noexcepttemplate<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 () noexceptconstexpr 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 &
no cap, that's the whole roster. copy them exactly, bestie, do not freestyle the template params. π
π Detailed Description π
template<typename _Tp>
class std::optional< _Tp >
"Class template for optional values." β literally the whole detailed description, and honestly? it ate. π
π«Ά Author π«Ά
Generated automatically by Doxygen for libstdc++ from the source code. so like, no human author to thank, it's a robot doing the most. π
and that's the page!! π shoutout to libstdc++ for the source and to this lil manpage's home in section 3cxx β that's where you'll find it, iykyk. go forth and emplace responsibly. π
β¨
π¦ where this page comes from
- ubuntu resolute: libstdc++-13-doc 13.4.0-10ubuntu1
- ubuntu stonking: libstdc++-13-doc 13.5.0-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms