Reputation: 4275
If I have,
void foo(Bar c);
void foo(Bar&& c);
foo(Bar());
why is the call to 'foo' is ambiguous? Isn't Bar() in the foo argument clearly an rValue?
Upvotes: 5
Views: 410
Reputation: 477408
Binding to a reference is an "exact match", as is binding to a non-reference, so both overloads are equally good.
In Standardese, this is 13.3.3.1.4 ("Reference binding", [over.ics.ref]):
When a parameter of reference type binds directly (8.5.3) to an argument expression, the implicit conversion sequence is the identity conversion [...]
Upvotes: 4