Is there a non-indirection, non-hack way to guarantee that a constexpr function only be callable at compile time?

前端 未结 1 976
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 08:29

At the moment, we have two primary options for compile-time evaluation: template metaprogramming (generally using template structs and/or variables), and constexpr

相关标签:
1条回答
  • 2020-12-19 08:57

    C++20 added consteval for this express purpose. A consteval function is a constexpr function that is guaranteed to be only called at compile time.

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