What is the function parameter equivalent of constexpr?

前端 未结 1 1975
温柔的废话
温柔的废话 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  RightRotate(unsigned int value) {
         ...
    }
    

    You'd then invoke it as

    RightRotate<137>(argument); // rotate is 137 here
    

    0 讨论(0)
提交回复
热议问题