STD::_ENABLE_DEFAULT_CONSTRUCTOR(3cxx)
π NAME π
std::_Enable_default_constructor< _Switch, _Tag > β a mixin helper to conditionally enable or disable the default constructor.
Ok bestie, so this page lives in the 3cxx manual (that's the libstdc++ C++ section, iykyk π ), and it's about one very specific little template that decides whether your type gets a default constructor or not. Yes, conditionally. Yes, it's giving "compiler please read my mind". Slay.
β¨ SYNOPSIS β¨
#include <enable_special_members.h>
Inherited by (all of these are [private] besties, no peeking π):
std::_Hashtable< _Key, _Tp, _Hash, _Pred, allocator< std::pair< const _Key, _Tp > > >[private]std::_Hashtable< _Key, _Tp, hash< _Key >, equal_to< _Key >, allocator< std::pair< const _Key, _Tp > > >[private]std::_Hashtable< _Value, hash< _Value >, equal_to< _Value >, allocator< _Value > >[private]std::_Enable_special_members< _Default, _Destructor, _Copy, _CopyAssignment, _Move, _MoveAssignment, _Tag >[private]std::_Hashtable< _Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits >[private]
π Public Member Functions π
constexpr _Enable_default_constructor (_Enable_default_constructor &&) noexcept=defaultβ the move constructor, and it'sconstexpr+noexcept+=default, so it's literally doing the bare minimum and doing it perfectly. main character energy βconstexpr _Enable_default_constructor (_Enable_default_constructor const &) noexcept=defaultβ the copy constructor, same deal,constexpr,noexcept, defaulted. iconic. πconstexpr _Enable_default_constructor (_Enable_default_constructor_tag)β okay THIS one, the tag constructor, this is the whole point of the entire struct. It takes an_Enable_default_constructor_tagand it's the one that actually flips the switch. obsessed π¦_Enable_default_constructor & operator= (_Enable_default_constructor &&) noexcept=defaultβ move assignment, defaulted andnoexcept, no notes. π_Enable_default_constructor & operator= (_Enable_default_constructor const &) noexcept=defaultβ copy assignment, defaulted andnoexcept. periodt. π
πΈ Detailed Description πΈ
template<bool _Switch, typename _Tag = void>
struct std::_Enable_default_constructor< _Switch, _Tag >
A mixin helper to conditionally enable or disable the default constructor.
That's the whole vibe bestie: you inherit from it, you hand it a bool for _Switch and a _Tag (which defaults to void btw, look at that typename _Tag = void β adorable), and it decides for you whether a default constructor exists at all. No cap, that's it. That's the function. π§
See also
_Enable_special_members
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
And that's the whole page, bestie! This little gem is part of the libstdc++ docs, and it's the std::_Enable_d..._Switch, _Tag >(3cxx) page β dated by the manpage footer. Go forth and conditionally construct, you absolute legend. π«Άβ¨π
π¦ where this page comes from
- ubuntu noble: libstdc++-10-doc 10.5.0-4ubuntu2
- ubuntu noble: libstdc++-10-doc 10.5.0-4ubuntu2.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms