Because it is fully valid C ++.
The function name is implicitly converted to a pointer to this function.
For MSVC, the standard library provides an output operator for arbitrary pointers, which prints the numeric value of that pointer.
For GCC / Clang, the result is a bit complicated: they (correctly) do not implement an insert that matches function pointers. Instead, the function pointer is implicitly converted to bool, which is true (1) since the pointer is not null. The conversion sequence can also be written explicitly so.
int(*p)(int, int) = elapsedtime; bool b = p; cout << "Your elapsed time is " << b <<endl;
Note that with the proper warning level, both g ++ and clang will warn you when an implicit conversion sequence causes the function name to true to true with a warning similar to:
warning: address of function 'elapsedtime' will always evaluate to 'true' [-Wbool-conversion]
source share