E designates an object o, and
if the complete object of o is of consteval-only type then so is E,
[Example 1: struct Base {};
struct Derived : Base { std::meta::info r; };
constevalconst Base& fn(const Derived& derived){return derived; }constexpr Derived obj{.r=^^::}; // OKconstexprconst Derived& d = obj; // OKconstexprconst Base& b = fn(obj); // error: not a constant expression because Derived// is a consteval-only type but Base is not. — end example]
A glvalue core constant expression
that either refers to or points to an unspecified object
is not a constant expression.
— end note]
[Example 2: constevalint f(){return42; }constevalauto g(){return f; }constevalint h(int(*p)()= g()){return p(); }constexprint r = h(); // OKconstexprauto e = g(); // error: a pointer to an immediate function is// not a permitted result of a constant expressionstruct S {int x;
constexpr S(){}};
int i(){constexpr S s; // error: s.x has erroneous value} — end example]
An integral constant expression
is an expression of integral or
unscoped enumeration type, implicitly converted to a prvalue, where the converted expression is a core constant expression.
Such expressions can be
used as bit-field lengths ([class.bit]), as enumerator
initializers if the underlying type is not fixed ([dcl.enum]),
and as alignments.
If an expression of literal class type is used in a context where an
integral constant expression is required, then that expression is
contextually implicitly converted ([conv]) to an integral or unscoped
enumeration type
and the selected conversion function shall be constexpr.
[Example 3: struct A {constexpr A(int i): val(i){}constexproperatorint()const{return val; }constexproperatorlong()const{return42; }private:int val;
};
constexpr A a =alignof(int);
alignas(a)int n; // error: ambiguous conversionstruct B {int n : a; }; // error: ambiguous conversion — end example]
A converted constant expression
of type T is an
expression, implicitly converted to type T, where
the converted expression is a constant expression and the
implicit conversion sequence contains only