Created on 2008-03-13.00:00:00 last changed 196 months ago
[Voted into the WP at the September, 2008 meeting (resolution in paper N2757).]
Notes from the September, 2008 meeting:
The resolution adopted as part of paper N2757 differs from the July, 2008 proposed resolution by allowing defaulted and user-provided special member functions to coexist. Instead, a trivial class is defined as having no non-trivial copy constructors or copy assignment operators, and a trivial copy constructor or assignment operator is defined as invoking only trivial copy operations for base and member subobjects.
Proposed resolution (July, 2008):
Change 9.5 [dcl.fct.def] paragraph 9 as follows:
... A special member function that would be implicitly defined as deleted shall not be explicitly defaulted. If a special member function for a class X is defaulted on its first declaration, no other special member function of the same kind (default constructor, copy constructor, or copy assignment operator) shall be declared in class X. A special member function is user-provided...
Part of the decision regarding whether a class has a trivial special function (copy constructor, copy assignment operator, default constructor) is whether its base and member subobjects have corresponding trivial member functions. However, with the advent of defaulted functions, it is now possible for a single class to have both trivial and nontrivial overloads for those functions. For example,
struct B { B(B&) = default; // trivial B(const B&); // non-trivial, because user-provided }; struct D : B { };
Although B has a trivial copy constructor and thus satisfies the requirements in 11.4.5.3 [class.copy.ctor] paragraph 6, the copy constructor in B that would be called by the implicitly-declared copy constructor in D is not trivial. This could be fixed either by requiring that all the subobject's copy constructors (or copy assignment operators, or default constructors) be trivial or that the one that would be selected by overload resolution be trivial.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | messages: + msg1829 |
2008-10-05 00:00:00 | admin | set | messages: + msg1828 |
2008-10-05 00:00:00 | admin | set | status: review -> cd1 |
2008-07-27 00:00:00 | admin | set | messages: + msg1727 |
2008-07-27 00:00:00 | admin | set | status: open -> review |
2008-03-13 00:00:00 | admin | create |