Difference between revisions of "cpp/concepts/copy constructible"
From cppreference.com
m (→See also) |
Andreas Krug (Talk | contribs) m (a lvalue -> an lvalue) |
||
Line 14: | Line 14: | ||
=== Semantic requirements === | === Semantic requirements === | ||
If {{tt|T}} is an object type, then {{tt|copy_constructible<T>}} is modeled only if given | If {{tt|T}} is an object type, then {{tt|copy_constructible<T>}} is modeled only if given | ||
− | * {{tt|v}}, | + | * {{tt|v}}, an lvalue of type (possibly {{c|const}}) {{tt|T}} or an rvalue of type {{c|const T}}, |
the following are true: | the following are true: | ||
* After the definition {{c|T u {{=}} v;}}, {{tt|u}} is equal to {{tt|v}} and {{tt|v}} is not modified; | * After the definition {{c|T u {{=}} v;}}, {{tt|u}} is equal to {{tt|v}} and {{tt|v}} is not modified; |
Revision as of 12:37, 15 January 2023
Defined in header <concepts>
|
||
template <class T> concept copy_constructible = |
(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 (possibly const)T
or an rvalue of type const T,
the following are true:
- After the definition T u = v;,
u
is equal tov
andv
is not modified; -
T(v)
is equal tov
and does not modifyv
.
See also
(C++11)(C++11)(C++11) |
checks if a type has a copy constructor (class template) |