Created on 2026-08-17.00:00:00 last changed 1 week ago
Consider:
constexpr int const& r = std::meta::extract<int const&>(^^r);
For the call to extract-ref, [meta.reflection.extract]/5.3 requires that, if the reflection represents a variable, either:
the variable is usable in constant expressions, or
its lifetime began within the core constant expression currently under evaluation.
The second does not apply, as [basic.life] says the lifetime of the reference begins after its initialization is complete.
The first, is circular. Determining whether `r` is usable in constant expression requires determining whether it is constant-initialized, which requires whether the full-expression of the initializer is a constant expression. Determining whether that full-expression is constant expression requires evaluating the call to extract, whose successful evaluation depends on the same determination that `r` is usable in constant expressions. Also, [meta.reflection.extract]/4 says the result is a reference to object referred by the represented variable, which during the initialization of `r`, doesn't exist yet. Apparent intent is presumably to make this ill-formed, but the current wording does not provide a non-circular way of reaching that conclusion. Suggested resolution: Require that the lifetime of the object or reference declared by the represented variable has already begun.| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-08-17 00:00:00 | admin | create | |