Difference between revisions of "cpp/named req/TriviallyCopyable"
From cppreference.com
(+) |
m (→Defect reports: apply CWG2094 to C++11, note CWG1746 instead) |
||
Line 17: | Line 17: | ||
{{dr list begin}} | {{dr list begin}} | ||
{{dr list item|wg=cwg|dr=1734|std=C++11|before=C++03 POD with deleted non-trivial assignment was not trivial|after=deleted ctors/operators allowed}} | {{dr list item|wg=cwg|dr=1734|std=C++11|before=C++03 POD with deleted non-trivial assignment was not trivial|after=deleted ctors/operators allowed}} | ||
− | {{dr list item|wg=cwg|dr=2094|std=C++ | + | {{dr list item|wg=cwg|dr=2094|std=C++11|before=Volatile scalar types are not trivially copyable (CWG 1746)|after=made trivially copyable}} |
{{dr list end}} | {{dr list end}} | ||
Revision as of 01:22, 15 August 2020
Requirements
- Every copy constructor is trivial or deleted
- Every move constructor is trivial or deleted
- Every copy assignment operator is trivial or deleted
- Every move assignment operator is trivial or deleted
- at least one copy constructor, move constructor, copy assignment operator, or move assignment operator is non-deleted
- Trivial non-deleted destructor
This implies that the class has no virtual functions or virtual base classes.
Scalar types and arrays of TriviallyCopyable objects are TriviallyCopyable as well.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
CWG 1734 | C++11 | C++03 POD with deleted non-trivial assignment was not trivial | deleted ctors/operators allowed |
CWG 2094 | C++11 | Volatile scalar types are not trivially copyable (CWG 1746) | made trivially copyable |
See also
(C++11) |
checks if a type is trivially copyable (class template) |