假设我们多次定义const或constexpr做简单的算术运算符,变量和函数调用也不会表示或返回常量。
#define NU = 3; //Macro or
const int NU = 3 // general declaration or constexpr
auto NU = []()constexpr -> int { return 3;}
int result = 0;
#Approach one -> const NU on left side of the operator right side could be function call or a function parameter
for(int i = 0; i< SOME_MAX; ++i) result = NU * foo(); // function call or
for(int i = 0; i< SOME_MAX; ++i) …Run Code Online (Sandbox Code Playgroud)