Why does passing by value and passing through rvalue overload the C ++ function ambiguous call?

if I have

void foo(Bar c);
void foo(Bar&& c);

foo(Bar()); 

why is the call to "foo" ambiguous? Is Bar () in the argument foo explicitly rValue?

+4
source share
1 answer

Linking to a link is an “exact match”, just like linking to a non-referent, so both overloads are equally good.

In Standardese, this is 13.3.3.1.4 ("Binding Link", [over.ics.ref]):

When a parameter of a reference type is directly associated (8.5.3) with an argument expression, the implicit conversion sequence is an identity transformation [...]

+4
source

All Articles