C++ Logo

std-proposals

Advanced search

Re: [std-proposals] switch expression/matching switch expression

From: Pavel Vazharov <freakpv_at_[hidden]>
Date: Wed, 14 May 2025 08:11:50 +0300
On Wed, May 14, 2025 at 8:09 AM Pavel Vazharov <freakpv_at_[hidden]> wrote:

>
> On Wed, May 14, 2025 at 8:05 AM Tymi via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> A matching switch expression could be useful and could get optimised into
>> a jump table
>> ```cpp
>> int meow = 5;
>> int purr = switch(meow)
>> {
>> case 5: 123;
>> case 123: 321;
>> default: throw nullptr;
>> };```
>> Whatever the syntax would be, this is just an example and it can
>> definitely improve
>>
> It's probably covered by the proposed pattern matching
> <https://wg21.link/p2688>
> And/or by the proposed do expressions <https://wg21.link/p2806>.
>
>>
>> Tymi.
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>

Received on 2025-05-14 05:12:03