C++ 23 · Language basics
Compute at compile time
A constexpr function can be evaluated while compiling, and static_assert checks it.
constexpr int square(int n) { return n * n; }
static_assert(square(4) == 16);
C++ 23 · Language basics
A constexpr function can be evaluated while compiling, and static_assert checks it.
constexpr int square(int n) { return n * n; }
static_assert(square(4) == 16);
Was this page helpful?