Herein, similar questions were asked for C#
:
Are arithmetic operations on literals in C# evaluated at compile time?,
and java
:
Are arithmetic operations on literals calculated at compile time or run time?.
Considering C++, will the following calculations be evaluated during run- or compile-time? The first is to define a built-in type, the second is to be a function argument.
Yet please consider them for all 4 basic arithmetic operations as well as with other built-in types, e.g. an int
instead of the double
below.
double testDouble = 2.0 + 2.0;
aUserDefinedType testUserDefinedTypeObject ( aMemberVariable*std::pow(someOtherVariable, 1.0/8.0) );