Created on 2009-12-17.00:00:00 last changed 174 months ago
Rationale (August, 2010):
The two functions are distinguished by partial ordering, so the call is not actually ambiguous.
In the following example,
template<typename T> void f(const T&); // #1 template<typename T> void f(T&&); // #2 void g() { const int x = 5; f(x); }
the call f(x) is ambiguous by the current rules. For #1, T is deduced as int, giving
f<int>(const int&)
For #2, because of the special case for T&& in 13.10.3.2 [temp.deduct.call] paragraph 3, T is deduced as const int&; application of the reference-collapsing rules in 9.3.4.3 [dcl.ref] paragraph 6 to the substituted parameter type yields
f<const int&>(const int&)
These are indistinguishable in overload resolution, resulting in an ambiguity. It's not clear how this might be addressed.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-08-23 00:00:00 | admin | set | messages: + msg2957 |
2010-08-23 00:00:00 | admin | set | status: open -> nad |
2009-12-17 00:00:00 | admin | create |