I have the following code:
struct S {
const bool x = true;
constexpr const bool& f() { return x; }
} s{};
int main() {
static_assert(s.f()); // error: s is not declared as 'constexpr';
}
Note that, this is a dupe for the question How to make this
pointer constant expression because the the expression E = s.f()
does not evaluates lvalue-to-rvalue conversion ([expr.const]/(5.8)).
Also, this question is not a dupe for the question How to get std array size in a constant expression because the expression E = s.f()
does evaluates this
in a constexpr function S::f
that's evaluated as part of the expression s.f()
([expr.const]/(5.1)).
Now my question is, which bullet in [expr.const]/5
(if any) is applied to the above example?