小编Bud*_*ika的帖子

带有任何算术运算符的常量操作数的顺序会影响优化吗?

假设我们多次定义constconstexpr做简单的算术运算符,变量和函数调用也不会表示或返回常量

    #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)

c++ optimization assembly compiler-optimization c++17

3
推荐指数
1
解决办法
98
查看次数