Created on 2009-05-13.00:00:00 last changed 189 months ago
[Voted into WP at March, 2010 meeting.]
Proposed resolution (October, 2009):
Change 12.2.2.5 [over.match.copy] paragraph 1 second bullet as follows:
Consider the following example:
struct C { };
struct A {
explicit operator int() const;
explicit operator C() const;
};
struct B {
int i;
B(const A& a): i(a) { }
};
int main() {
A a;
int i = a;
int j(a);
C c = a;
C c2(a);
}
It's clear that the B constructor and the declaration of j are well-formed and the declarations of i and c are ill-formed. But what about the declaration of c2? This is supposed to work, but it doesn't under the current wording.
C c2(a) is direct-initialization of a class, so constructors are considered. The only possible candidate is the default copy constructor. So we look for a conversion from A to const C&. There is a conversion operator to C, but it is explicit and we are now performing copy-initialization of a reference temporary, so it is not a candidate, and the declaration of c2 is ill-formed.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-03-29 00:00:00 | admin | set | messages: + msg2724 |
| 2010-03-29 00:00:00 | admin | set | status: ready -> cd2 |
| 2009-11-08 00:00:00 | admin | set | messages: + msg2369 |
| 2009-11-08 00:00:00 | admin | set | status: open -> ready |
| 2009-05-13 00:00:00 | admin | create | |