std::copy_constructible
Defined in header <concepts> | ||
|---|---|---|
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>;
| (since C++20) |
The concept 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 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).
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.
References
- C++23 standard (ISO/IEC 14882:2024):
- 18.4.14 Concept
copy_constructible[concept.copyconstructible] - C++20 standard (ISO/IEC 14882:2020):
- 18.4.14 Concept
copy_constructible[concept.copyconstructible]
See also
|
(C++11)(C++11)(C++11) | checks if a type has a copy constructor (class template) |
|
(C++26)(C++26)(C++26) | checks if reflected type has a copy constructor (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/concepts/copy_constructible