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 the call to foo( static_cast< int&& >(1) )
is ambiguous:
error: call to 'foo' is ambiguous
foo( static_cast<int&&>(1) );
^~~
Because of the explicit cast to int&&
, I expected that void foo( int&& in )
will be called.