I found the term in this chain of concepts:
(1) trivially copyable constructor
(2) trivial defaut constructor (defined from (1) )
(3) trivialType (defined from(2))
Techinically, I understand all the concepts (like what exactly it contains)
Semantically, I don't understand the term "trivial" (explain why I keep forgeting the chain).
I try to look up the word in as many dictionaries as possible, but no sense of it make sense to me, and here is my work (if any one care):
--------------------
*trivial:
Terms such as trivial are defined in the C++ standard, and you can look up their definitions. Those are most easily found in the index of the latest working draft.
Intuitively, a trivial type is a type where all operations (default construction, copying, destruction, ...) are equivalent to doing nothing, or performing std::memmove from one object to another (ignoring padding). int is a trivial type for example, since construction and destruction of an int requires no action, and copying it is just copying its bytes (as if by std::memmove).
Formally, [basic.types.general] p9 defines what a trivial type is. In short, it's a scalar type (e.g. int, void*, etc.), an array of trivial types, or a trivial class.
A trivial class is a class that is trivially copyable and has one or more eligible default constructors, all of which are trivial.
- [class.prop] p2
A default constructor is trivial if it is not user-provided and if:
- [...]
- [class.default.ctor] p3
In short, it means that a default constructor "has to do nothing" to be trivial. From this and other definitions, you can figure out exactly what the C++ standard means by trivial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With