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:09:35 +0300
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>

>
> Tymi.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2025-05-14 05:09:46