编译时运行函数
标准: C++14, C++20, C++23.
相关的关键字:
- constexpr: 可以在编译时计算.
- consteval: 必须在编译时计算.
constexpr
- C++14
- 支持在函数中使用变量/for循环.
- C++20
std::is_constant_evaluated()
可以用于判断当前是在进行编译时计算还是运行时计算.- 支持
std::vector
/std::string
/std::map
. - 支持
new
.
标准: C++14, C++20, C++23.
相关的关键字:
std::is_constant_evaluated()
可以用于判断当前是在进行编译时计算还是运行时计算.std::vector
/std::string
/std::map
.new
.