Summary
This episode introduces C++20's consteval keyword, which enforces that a function must be evaluated at compile time. Jason explains that consteval is similar to constexpr but more restrictive, as it guarantees immediate compile-time evaluation rather than permitting both compile-time and runtime evaluation. He demonstrates how consteval functions fail to compile when used with non-constant expressions and discusses practical applications, including std::source_location from the standard library.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[constexpr.functions]64% match -
[meta.const.eval]63% match -
[diff.cpp03.expr]54% match -
[diff.cpp11.dcl.dcl]50% match -
[support.srcloc.class]40% match