C++ Logo

liaison

Advanced search

Re: [isocpp-wg14/wg21-liaison] WG21 feedback required - N3538

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Mon, 05 May 2025 21:59:16 +0200
Hi

Am 5. Mai 2025 20:23:02 MESZ schrieb Zhihao Yuan <zy_at_[hidden]>:
> 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

Not for my eyes, sorry

> 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.
> _______________________________________________
>


-- 
Jens Gustedt - INRIA & ICube, Strasbourg, France 

Received on 2025-05-05 19:59:22