Why is pass by value and pass by rvalue overload c++ function call ambiguous?
问题 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? 回答1: 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 [...] 来源: