<html>
<head>
<title>P0398R0: Core issue 1518: Explicit default constructors and copy-list-initialization </title>

<style type="text/css">
  ins { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  del { text-decoration:line-through; background-color:#FFA0A0 }  
  strong { font-weight: inherit; color: #2020ff }
  table, td, th { border: 1px solid black; border-collapse:collapse; padding: 5px }
</style>
</head>

<body>
ISO/IEC JTC1 SC22 WG21 P0398R0<br/>
Group: Core Working Group<br/>
Jens Maurer &lt;Jens.Maurer@gmx.net><br/>
2016-06-24<br/>

<h1>P0398R0: Core issue 1518: Explicit default constructors and copy-list-initialization </h1>

<h2>Introduction</h2>

As directed by CWG in Oulu, a class that declares an explicit default
constructor or has inherited constructors should cease being an aggregate.

<h2>Wording</h2>

Change in 8.5.1 [dcl.init.aggr] paragraph 1:

<blockquote>
  An aggregate is an array or a class (Clause 9) with
  <ul>
    <li>no user-provided, <ins><code>explicit</code>, or
      inherited</ins> constructors (12.1) <del>(including those
      inherited (7.3.3) from a base class)</del>,</li>
    <li>...</li>
  </ul>
  
</blockquote>

Change in 13.3.1.3 [over.match.ctor] paragraph 1:

<blockquote>
When objects of class type are direct-initialized (8.5),
copy-initialized from an expression of the same or a derived class
type (8.5), or default-initialized (8.5), overload resolution selects
the constructor. For direct-initialization or
default-initialization <strong><ins>that is not in the context of
copy-initialization</ins></strong>, the candidate functions are all the
constructors of the class of the object being initialized. For
copy-initialization, the candidate functions are all the converting
constructors (12.3.1) of that class. The argument list is
the <em>expression-list</em> or
<em>assignment-expression</em> of the initializer.
</blockquote>

Change in 12.3.1 [class.conv.ctor] paragraphs 1 and 2:

<blockquote>
A constructor declared without
the <em>function-specifier</em> <code>explicit</code> specifies a
conversion from the types of its parameters <ins>(if any)</ins> to the
type of its class. Such a constructor is called a <em>converting
constructor</em>. [ Example: ... ]

<p>

 [ Note: An explicit constructor constructs objects just like
non-explicit constructors, but does so only where the
direct-initialization syntax (8.5) or where casts (5.2.9, 5.4) are
explicitly used; see also 13.3.1.4. A default constructor may be an
explicit constructor; such a constructor will be used to perform
default-initialization or value-initialization (8.5). [
Example:
 <pre>
struct Z {
  explicit Z();
  explicit Z(int);
  explicit Z(int, int);
};
Z a;                      // OK: default-initialization performed
<ins>Z b{};                    // OK: direct initialization syntax used
Z c = {};                 // error: copy-list-initialization</ins>
Z a1 = 1;                 // error: no implicit conversion
Z a3 = Z(1);              // OK: direct initialization syntax used
Z a2(1);                  // OK: direct initialization syntax used
Z* p = new Z(1);          // OK: direct initialization syntax used
Z a4 = (Z)1;              // OK: explicit cast used
Z a5 = static_cast&lt;Z>(1); // OK: explicit cast used
Z a6 = { 3, 4 };          // error: no implicit conversion
     </pre>
-- end example ] -- end note ] 
</blockquote>

</body>
</html>
