How to ensure constexpr function never called at runtime?

后端 未结 5 1040
无人及你
无人及你 2020-12-05 18:52

Lets say that you have a function which generates some security token for your application, such as some hash salt, or maybe a symetric or asymetric key.

Now lets sa

5条回答
  •  孤街浪徒
    2020-12-05 19:17

    In the upcoming C++20 there will be consteval specifier.

    consteval - specifies that a function is an immediate function, that is, every call to the function must produce a compile-time constant

提交回复
热议问题