Regarding the following code:
void foo( int in ) { std::cout << "no ref" << std::endl; } void foo( int&& in ) { std::cout << "ref&&" << std::endl; } int main() { foo( static_cast<int&&>(1) ); return 0; }
I wonder why calling foo( static_cast< int&& >(1) ) ambiguous:
error: call to 'foo' is ambiguous foo( static_cast<int&&>(1) ); ^~~
Due to the explicit cast to int&& I expected void foo( int&& in ) be called.
c ++ rvalue-reference function-overloading
abraham_hilbert
source share