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's constexpr + 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_tag and it's the one that actually flips the switch. obsessed πŸ¦‹
  • _Enable_default_constructor & operator= (_Enable_default_constructor &&) noexcept=default β€” move assignment, defaulted and noexcept, no notes. πŸ‘‘
  • _Enable_default_constructor & operator= (_Enable_default_constructor const &) noexcept=default β€” copy assignment, defaulted and noexcept. 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