12.6.1 - Explicit initialization
struct complex {
complex();
complex(double);
complex(double,double);
};
complex sqrt(complex,complex);
The constructor-from-T
is not explicit, and copy-list-initialization is not the same as copy-initialization. Both cause "constructors to be considered", but copy-initialization always "considers" the copy constructor, while list-initialization considers constructors with the list elements filled in (plus some details). To wit:
struct Foo
{
Foo(int) {}
Foo(Foo const &) = delete;
};
int main()
{
Foo f = { 1 }; // Fine
}
(This would fail if the constructor was explicit
. Also, Foo x = 1;
will of course fail on account of the deleted copy constructor.)
Perhaps an even more enlightening use case:
Foo make() { return { 2 }; }
void take(Foo const &);
take(make());
Everything necessary for this is in 8.5.4/3 and in 13.3.1.7/1.