Created on 2010-12-03.00:00:00 last changed 165 months ago
Rationale (March, 2011):
The current rules are as intended.
The rules for selecting candidate functions in copy-list-initialization (12.2.2.8 [over.match.list]) differ from those of regular copy-initialization (12.2.2.5 [over.match.copy]): the latter specify that only the converting (non-explicit) constructors are considered, while the former include all constructors but state that the program is ill-formed if an explicit constructor is selected by overload resolution. This is counterintuitive and can lead to surprising results. For example, the call to the function object p in the following example is ambiguous because the explicit constructor is a candidate for the initialization of the operator's parameter:
struct MyList { explicit MyStore(int initialCapacity); }; struct MyInt { MyInt(int i); }; struct Printer { void operator()(MyStore const& s); void operator()(MyInt const& i); }; void f() { Printer p; p({23}); }
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-04-10 00:00:00 | admin | set | messages: + msg3418 |
2011-04-10 00:00:00 | admin | set | status: open -> nad |
2010-12-03 00:00:00 | admin | create |