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);

Official C++ 23 documentation

More language basics commands

All language basics commands · C++ 23 cheatsheet

Was this page helpful?