What is the function parameter equivalent of constexpr?

前端 未结 1 2000
温柔的废话
温柔的废话 2021-01-23 14:49

We are trying to speedup some code under Clang and Visual C++ (GCC and ICC is OK). We thought we could use constexpr to tell Clang a value is a compile tim

相关标签:
1条回答
  • 2021-01-23 15:15

    You could use non-type template arguments for this:

    template <unsigned int rotate> RightRotate(unsigned int value) {
         ...
    }
    

    You'd then invoke it as

    RightRotate<137>(argument); // rotate is 137 here
    
    0 讨论(0)
提交回复
热议问题