std::copy_constructible(3)
π NAME π
std::copy_constructible β std::copy_constructible, bestie. That's the whole name, no notes. This is the std::copy_constructible(3) page from the C++ Standard Libary manual β yes, βLibary,β and we love a chaotic spelling moment π
π¦ Synopsis π¦
Defined in header <concepts>.
(since C++20)
template< class T >
concept copy_constructible =
std::move_constructible<T> &&
std::constructible_from<T, T&> && std::convertible_to<T&, T> &&
std::constructible_from<T, const T&> && std::convertible_to<const
T&, T> &&
std::constructible_from<T, const T> && std::convertible_to<const
T, T>;
Okay so the vibe check: copy_constructible is satisfied if T is an lvalue reference type, or if it is a move_constructible object type where an object of that type can be constructed from a (possibly const) lvalue or const rvalue of that type in both direct- and copy-initialization contexts with the usual semantics (a copy is constructed with the source unchanged). No cap, the source stays untouched π«Ά
π§ Semantic requirements π§
If T is an object type, then copy_constructible<T> is modeled only if given
v, an lvalue of type (possiblyconst)Tor an rvalue of typeconst T,
the following are true:
- After the definition
T u = v;,uis equal tovandvis not modified; T(v)is equal tovand does not modifyv.
π See also π
The see-also crew β all (C++11), all (class template), and the pageβs description is checks if a type has a copy constructor:
is_copy_constructibleβ(C++11),(class template)is_trivially_copy_constructibleβ(C++11),(class template)is_nothrow_copy_constructibleβ(C++11),(class template)
Sign-off, because we keep it cute: source http://cppreference.com, version/date 2024.06.10, page std::copy_constructible(3). Go off and copy-construct responsibly, bestie πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms