C++ Logo

std-proposals

Advanced search

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

From: Tymi <tymi.cpp_at_[hidden]>
Date: Wed, 14 May 2025 07:08:17 +0200
```cpp
int purr = meow == 5 ? 123
     : meow == 123 ? 321
     : throw nullptr;
```
This is what I do now


On Wed, 14 May 2025, 07:05 Tymi, <tymi.cpp_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
>
> Tymi.
>

Received on 2025-05-14 05:08:29