Trivial constructors and destructors

Does the fact that an implicitly declared constructor(default, copy, move) or destructor is trivial - triggers the compiler to define / not to define it?

cppreference says yes, but standard doesn't mention the dependence in $12.1

Both gcc and clang define implicitly declared default destructor, copy constructor independently from their being trivial or not.
cppreference actually says http://en.cppreference.com/w/cpp/language/copy_constructor#Implicitly-defined_copy_constructor

If the implicitly-declared copy constructor is neither deleted nor trivial, it is defined (that is, a function body is generated and compiled) by the compiler if odr-used.
(same for move, and I just fixed default where "odr used" was omitted. Where does it link it to triviality?)

It's the ODR-use http://en.cppreference.com/w/cpp/language/definition#ODR-use that triggers the definition. Trivial just explains what it does (nothing for default, memcpy equivalnet for copy/move)
Last edited on
"is neither deleted nor trivial, it is defined"
Does it mean that copy/move constructor copy/move assignment operator won't be defined if it's trivial?

Now it's irrelevant, but I downloaded the page on default constructor from cppreference some time ago and it said "If the implicitly-declared default constructor is not deleted or trivial, it's defined" .
As I understand, that page is already fixed.
Last edited on
"is neither deleted nor trivial, it is defined"

ah, it was a bug in cppreference wording, fixed september 2015 by this edit: http://en.cppreference.com/mwiki/index.php?title=cpp%2Flanguage%2Fdefault_constructor&diff=80876&oldid=80493
So, if it's trivial it's not defined?
I understood it this way:

if(!deleted && !trivial) => defined
therefore
if(trivial) => not defined

no, "trivial" has nothing to do with "defined".
So, instead of "if neither deleted nor trivial, it is defined "
should be written
"if not deleted, it's defined"
, right?
if not deleted and if ODR-used, then it is defined. See my first reply or the online cppreference
Thanks. Now I got it.
Topic archived. No new replies allowed.