C++ Logo

std-proposals

Advanced search

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

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Wed, 14 May 2025 12:40:28 +0300
On 14 May 2025 08:05, Tymi via Std-Proposals 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

How would it be better than a usual switch/case?

Received on 2025-05-14 09:40:30