Date: Mon, 05 May 2025 18:23:02 +0000
On Monday, May 5th, 2025 at 9:31 AM, Jāāā Gustedt via Liaison <liaison_at_[hidden]> wrote:
>
> But still, having a lambda just to have a place for doing a
> `static_assert`, looks a bit of an overkill, at the same level of what
> is described in the paper as C solution with a compound literal of an
> auxiliary `struct` type.
>
> But even with a Ī», you'd have to make it
> compose with whatever expression you want to do in that place where
> you use the `static_assert`. So I don't have the impression that
> becomes much easier in C++.
>
My subconscious response is not lambda
expressions, but "do expressions" from
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2806r3.html
This will allow
#define BIT(n) do { \
static_assert(n >= 0); \
static_assert(n < sizeof(unsigned int) * CHAR_BIT); \
do_return 1U << (n); \
}
Presumably more readable and enables the
possibility of writing a function-like
macro that `break`s out of a loop.
>
> But still, having a lambda just to have a place for doing a
> `static_assert`, looks a bit of an overkill, at the same level of what
> is described in the paper as C solution with a compound literal of an
> auxiliary `struct` type.
>
> But even with a Ī», you'd have to make it
> compose with whatever expression you want to do in that place where
> you use the `static_assert`. So I don't have the impression that
> becomes much easier in C++.
>
My subconscious response is not lambda
expressions, but "do expressions" from
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2806r3.html
This will allow
#define BIT(n) do { \
static_assert(n >= 0); \
static_assert(n < sizeof(unsigned int) * CHAR_BIT); \
do_return 1U << (n); \
}
Presumably more readable and enables the
possibility of writing a function-like
macro that `break`s out of a loop.
-- Zhihao Yuan, ID lichray The best way to predict the future is to invent it. _______________________________________________
Received on 2025-05-05 18:23:13