Created on 2016-08-09.00:00:00 last changed 100 months ago
Consider:
struct X { X(); }; X make(); X x{make()};
We reach 9.4.5 [dcl.init.list] bullet 3.7:
Otherwise, if T is a class type, constructors are considered. The applicable constructors are enumerated and the best one is chosen through overload resolution (12.2 [over.match], 12.2.2.8 [over.match.list]).
This means we perform a redundant copy. If T were an aggregate, 9.4.5 [dcl.init.list] bullet 3.2 would avoid the redundant copy:
If T is an aggregate class and the initializer list has a single element of type cv U, where U is T or a class derived from T, the object is initialized from that element (by copy-initialization for copy-list-initialization, or by direct-initialization for direct-list-initialization).
History | |||
---|---|---|---|
Date | User | Action | Args |
2016-08-09 00:00:00 | admin | create |