Tutorial by Examples: constexpr

A variable declared constexpr is implicitly const and its value may be used as a constant expression. Comparison with #define A constexpr is type-safe replacement for #define based compile-time expressions. With constexpr the compile-time evaluated expression is replaced with the result. For examp...
A function that is declared constexpr is implicitly inline and calls to such a function potentially yield constant expressions. For example, the following function, if called with constant expression arguments, yields a constant expression too: C++11 constexpr int Sum(int a, int b) { return ...

Page 1 of 1