5.2.9 /
-2- An expression e can be explicitly converted to a type T using a static_cast of the form static_cast<T>(e) if the declaration ``"T t(e);"'' is well-formed, for some invented temporary variable t (dcl.init). The effect of such an explicit conversion is the same as performing the declaration and initialization and then using the temporary variable as the result of the conversion. <cont...>
So, given:
float my_float = ...;
... this is...
f(static_cast<float>(my_float));
... should be equivalent ...
float temp = my_float; f(temp);
Whether this is done literally literally and generates a timeline in non-optimized builds, it depends on the compiler. If you do not trust your optimizer to remove this (if it has ever been inserted), you should try another compiler ...; -).
source share