STD::_OPTIONAL_BASE(3cxx)
β¨ std::_Optional_base< _Tp, bool, bool > β¨
okay bestie, welcome to the 3cxx manual π you're reading the page for std::_Optional_base< _Tp, bool, bool >, and yes the name is a whole mouthful, we love that for it π«Ά
πΈ NAME πΈ
std::_Optional_base< _Tp, bool, bool > β the class template that hands optional its copy/move constructors. that's literally its whole job. main character behavior, honestly π
π SYNOPSIS π
#include <optional>
Inherited by std::experimental::fundamentals_v1::optional< _Tp > [private], and std::optional< _Tp > [private]. so likeβ¦ two very iconic children, both keeping it private πβ¨
π Public Member Functions
constexpr _Optional_base (_Optional_base &&__other)noexcept(is_nothrow_move_constructible_v< _Tp >)β move-constructs from another one. no cap, whether it'snoexceptdepends entirely on whether_Tpis nothrow move constructible.constexpr _Optional_base (const _Optional_base &__other)β copies from another one. classic.template<typename... _Args, enable_if_t< is_constructible_v< _Tp, _Args... >, bool > = false> constexpr _Optional_base (in_place_t, _Args &&... __args)β thein_place_tone, where you hand it args and it builds the value right there in place. only exists when_Tpis constructible from those_Args..., otherwise SFINAE just quietly deletes it from existence πtemplate<typename _Up, typename... _Args, enable_if_t< is_constructible_v< _Tp, initializer_list< _Up > &, _Args... >, bool > = false> constexpr _Optional_base (in_place_t, initializer_list< _Up > __il, _Args &&... __args)β same energy but with aninitializer_list< _Up > __ilin the mix. also gated on constructibility, bestie._Optional_base & operator= (_Optional_base &&)=defaultβ move assignment, defaulted. periodt._Optional_base & operator= (const _Optional_base &)=defaultβ copy assignment, defaulted. also periodt.
β¨ Public Attributes
_Optional_payload< _Tp > _M_payloadβ the actual payload member. the whole vibe lives in here π
π§ Protected Types
using _Stored_typeβ a protected type alias. mysterious. lowkey iconic.
π Protected Member Functions
template<typename... _Args> constexpr void _M_construct (_Args &&... __args)noexcept(is_nothrow_constructible_v< _Stored_type, _Args... >)β constructs the stored thing-y from__args. its nothrow-ness is inherited from whether_Stored_typeis nothrow constructible from those args.constexpr void _M_destruct () noexceptβ destroys it. no drama, markednoexcept.constexpr const _Tp & _M_get () const noexceptβ const getter, returns aconst _Tp &.constexpr _Tp & _M_get () noexceptβ non-const getter, returns a_Tp &. yes there are two, we love overloading πconstexpr bool _M_is_engaged () const noexceptβ are we engaged or not?? (as in, does it hold a value. not, like, romantically. though π)constexpr void _M_reset () noexceptβ resets everything. goodbye value π
π Detailed Description π
template<typename _Tp, bool = is_trivially_copy_constructible_v<_Tp>, bool = is_trivially_move_constructible_v<_Tp>>
struct std::_Optional_base< _Tp, bool, bool >
"Class template that provides copy/move constructors of optional." yes ma'am π
okay so here's the tea β a separate base class template like this is necessary so that the copy/move constructors can be conditionally trivial. it's giving "i have to be my own class to make my constructors behave."
when the contained value is trivially copy/move constructible, the copy/move constructors of _Optional_base will invoke the trivial copy/move constructor of _Optional_payload. and otherwise?? they will invoke _Optional_payload(bool, const _Optional_payload&) or _Optional_payload(bool, _Optional_payload&&) to initialize the contained value β but only if we're copying/moving an engaged optional π«Ά
and whether the other special members are trivial is determined by the _Optional_payload<_Tp> specialization used for the _M_payload member. iykyk.
π See also
optional, _Enable_special_members
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. not a human bestie, just the machines doing their little machine thing π€β¨
β οΈ heads up: this is auto-generated Doxygen output for libstdc++, on the 3cxx manual β that's the vibe, that's the source, no cap.
okay that's the whole page, you ate it π
go forth and understand your _Optional_base the way it deserves, bestie. libstdc++ out here, 3cxx manual, generated by Doxygen, mwah π
π¦ where this page comes from
- ubuntu resolute: libstdc++-11-doc 11.5.0-11ubuntu2
- ubuntu resolute: libstdc++-12-doc 12.5.0-9ubuntu1
- ubuntu resolute: libstdc++-13-doc 13.4.0-10ubuntu1
- ubuntu stonking: libstdc++-11-doc 11.5.0-11ubuntu2
- ubuntu stonking: libstdc++-12-doc 12.5.0-9ubuntu1
- 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