Function Overloading Based on Value vs. Const Reference
问题 Does declaring something like the following void foo(int x) { std::cout << "foo(int)" << std::endl; } void foo(const int &x) { std::cout << "foo(const int &)" << std::endl; } ever make sense? How would the caller be able to differentiate between them? I've tried foo(9); // Compiler complains ambiguous call. int x = 9; foo(x); // Also ambiguous. const int &y = x; foo(y); // Also ambiguous. 回答1: The intent seems to be to differenciate between invocations with temporaries (i.e. 9 ) and 'regular'