C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Expanding constinit

From: Jan Schultke <janschultke_at_[hidden]>
Date: Fri, 26 Jan 2024 14:41:17 +0100
I find the "static constexpr" syntax in expressions confusing. If you
want to go into this direction on a per-expression basis, how about a
"consteval operator"?

> some_function_call(x, consteval(y));

In this example, x would not be evaluated as a constant expression,
but y would be. This would be a very powerful tool because it would do
two things for you:

> int x = consteval(y);

This is effectively "constinit int x = y".

> requires { consteval(y); }

This tests whether y can be evaluated as a constant expression.

Received on 2024-01-26 13:41:29