?
Die relevanten Passagen sind die hier (aus dem Entwurf N1804.pdf):
§8.5/11:
The form of initialization (using parentheses or is generally insignificant, but does matter when the entity being initialized has a class type...
§8.5/12:
The initialization that occurs in argument passing, function return, throwing an exception, handling an exception, and brace-enclosed initializer lists is called copy-initialization and is equivalent to the form
T x = a;
§8.5/13:
The initialization that occurs in new expressions, static_cast expressions, functional notation type conversions, and base and member initializers is called direct-initialization and is equivalent to the form
T x(a);
§8.5/15:
The semantics of initializers are as follows. The destination type is the type of the object or reference being initialized and the source type is the type of the initializer expression. The source type is not defined when the initializer is brace-enclosed or when it is a parenthesized list of expressions.
...
If the destination type is a (possibly cv qualified) class type
...
If the initialization is direct-initialization, or if it is copy-initialization where the cv-unqualified version of the source type is the same class as, or a derived class of, the class of the destination, constructors are considered. The applicable constructors are enumerated, and the best one is chosen through overload resolution. The constructor so selected is called to initialize the object, with the initializer expression(s) as its argument(s). If no constructor applies, or the overload resolution is ambiguous, the initialization is ill-formed.
Otherwise (i.e., for the remaining copy-initialization cases), user-defined conversion sequences that can convert from the source type to the destination type or (when a conversion function is used) to a derived class thereof are enumerated as described in 13.3.1.4, and the best one is chosen through overload resolution. If the conversion cannot be done or is ambiguous, the initialization is ill-formed. The function selected is called with the initializer expression as its argument; if the function is a constructor, the call initializes a temporary of the cv-unqualified version of the destination type. The temporary is an rvalue. The result of the call (which is the temporary for the constructor case) is then used to direct-initialize, according to the rules above, the object that is the destination of the copy-initialization. In certain cases, an implementation is permitted to eliminate the copying inherent in this direct-initialization by constructing the
intermediate result directly into the object being initialized; see 12.2, 12.8.
...
Aus §8.5/15 geht allerdings nicht hervor, dass bei der Kopierinitialisierungssyntax zum Initialisieren des Zielobjektes keine "expliziten" Konstruktoren in Frage kommen. Das steht dann hier:
§12.3.1/2:
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.
Das bedeutet also, dass
Klasse x = Klasse(1,2,3);
nur dann funktioniert, falls der copy-ctor public und nicht explizit ist. Hier wird logisch gesehen ein temporäres Objekt erzeugt und dann kopiert. Das Kopieren kann wegoptimiert werden (siehe §12.8). Ein copy-ctor muss trotzdem verfügbar sein, auch wenn er nicht benutzt wird. Wir haben nur im Fall
Klasse x (1,2,3);
die Garantie, dass kein unnötiges temporäres Objekt entsteht.
Falls das Quellobjekt kein temporäres ist wie hier:
Klasse x = ...;
Klasse y = x; // #1
Klasse z (x); // #2
passiert bei #1 und #2 genau dasselbe, sofern #1 und #2 legal sind. #1 wird aber nicht funktionieren, wenn der copy-ctor privat und/oder explizit ist.
kk