std::constructible_from(3cxx)
π 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_Tpgenuinely 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 πβ¨π
π¦ where this page comes from
- ubuntu resolute: libstdc++-12-doc 12.5.0-9ubuntu1
- ubuntu resolute: libstdc++-13-doc 13.4.0-10ubuntu1
- ubuntu resolute: libstdc++-16-doc 16-20260322-1ubuntu1
- ubuntu stonking: libstdc++-12-doc 12.5.0-9ubuntu1
- ubuntu stonking: libstdc++-13-doc 13.5.0-1ubuntu1
- ubuntu stonking: libstdc++-16-doc 16.2.0-3ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms