#include <iostream>
void f( int num )
{
std::cout << num << std::endl;
}
int main()
{
f( int( 5 ) );
return ( 0 );
}
Does line 10 cast literal 5 to an integer, stores the result in a temporary int and pass that one to f(), or creates it a temporary integer using the int ctor and passes that one?
int(5) is, by definition, the same as (int)5, which is the same as static_cast<int>(5).
There is no "int constructor" for the static cast to call, and the type of 5 is already int, so it does nothing ( theoretically, it builds a new prvalue temporary of type int, with value 5)