cpp/language/constexpr


 * - specifies that the value of a variable or function can appear in s

Explanation
The specifier declares that it is possible to evaluate the value of the function or variable at compile time. Such variables and functions can then be used where only compile time s are allowed (provided that appropriate function arguments are given).

A specifier used in an object declaration  implies. A specifier used in a function  declaration implies. If any declaration of a function or function template has a specifier, then every declaration must contain that specifier.

variable
A  variable must satisfy the following requirements:


 * its type must be a.
 * it must be immediately initialized
 * the of its initialization, including all implicit conversions, constructors calls, etc, must be a

function
A  function must satisfy the following requirements:


 * for constructor, the class must have no virtual base classes

{{rrev|until=c++23| {{anchor|constexpr constructor}}

constructor
A  constructor whose function body is not must satisfy the following additional requirements:


 * every constructor selected to initializing non-static data members and base class must be a constexpr constructor.

destructor
}}

For constexpr function templates and constexpr member functions of class templates, at least one specialization must satisfy the abovementioned requirements. Other specializations are still considered as constexpr, even though a call to such a function cannot appear in a constant expression.