std::constructible_from(3cxx)

πŸ“¦
version 16-20260322 Β· 3 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– std::constructible_from β€” the 3cxx manual page, but make it make sense πŸ’–

okay bestie, welcome to the <concepts> girlies' corner of the libstdc++ manual πŸ’… this one's called std::constructible_from and it lives in manual section 3cxx, so you already know it's C++ library business. it's a concept, fr fr β€” like, a compile-time vibe check. let's get into it πŸ¦‹


✨ NAME ✨

std::constructible_from β€” that's the [concept.constructible] one, the concept named constructible_from πŸ’–

so yes, the full glow-up name is std::constructible_from, and its standard-y home address is [concept.constructible]. both of those are the same girl. periodt.


🌸 SYNOPSIS 🌸

first things first, you gotta invite her in:

#include <concepts>

Concept definition

template<typename _Tp, typename... _Args>
concept std::constructible_from =  destructible<_Tp> && is_constructible_v<_Tp, _Args...>

look at her. iconic. two requirements, and _Tp has to pass both to get in the club πŸŽ€

  • it needs destructible<_Tp> to be true β€” you can't construct a thing you can't clean up after, bestie, that's just rude πŸ™ˆ
  • and is_constructible_v<_Tp, _Args...> has to be true β€” so _Tp genuinely has to be constructible from that pack of _Args... ⭐

it's an &&, not an ||. both. always both. no shortcuts, no cap πŸ”₯


🌈 DESCRIPTION 🌈

so what is this? it's [concept.constructible], the concept constructible_from πŸ’œ that's the whole bit β€” she's a concept that checks whether a type can be constructed from a given set of argument types, and whether it's destructible, all in one tidy named constraint so you can slap it on your templates and let the compiler do the gatekeeping for you πŸ‘‘

ngl, this is the kind of thing that makes template error messages slightly less of a jumpscare. slightly. πŸ’€

lowkey important: this is a concept, so it's a compile-time thing. nothing runs, nothing allocates, nothing happens at runtime. it's just the compiler going "hmm, vibe check... passed ✨" or "not today, girl πŸ’…".

🫢 AUTHOR 🫢

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

so nobody hand-wrote this bad boy β€” Doxygen just did its little automated slay and pulled it straight from the libstdc++ source 🌸 respect the pipeline, honestly.


🧚 SEE ALSO 🧚

okay so this page doesn't list any SEE ALSO entries, bestie β€” she's standing on her own two feet, main character energy, no entourage πŸ‘‘ but like, she does hang out in <concepts>, so that's where you'll find her friends.


and that's the whole page, no notes πŸ’–

this little beauty ships with libstdc++ and is filed under std::constructible_from(3cxx) β€” that's the manual, that's the name, that's the whole footer situation. go forth and constrain your templates responsibly, bestie πŸŽ€βœ¨πŸ’œ