Note: the standard doesn't define a named requirement with this name. This is a type category defined by the core language. It is included here as a named requirement only for consistency.
The following types are collectively called trivially copyable types:
In general, for any trivially copyable type
T and an object
T, the underlying bytes of
obj1 can be copied into an array of
unsigned char, or
std::byte (since C++17) or into
obj2, a distinct object of
obj2 may be a potentially-overlapping subobject.
If the underlying bytes of
obj1 are copied into such an array, and then the resulting content is copied back into
obj1 will hold its original value. If the underlying bytes of
obj1 are copied into
obj2 will hold
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|
| checks if a type is trivially copyable
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.