ARTICLE AD BOX
I'm newer to C++, but not new to programming. Is there any possibility of getting something similar-looking to a C# style switch expression in C++? In C# there is this style of pattern matching with switch-looking statements (Microsoft Docs):
var value = rand.Next(10) switch { <3 => "apple (30%)", <7 => "banana (40%)", _ => "orange (30%)" };There are more intricate applications than this, but I figured it was enough for an example. Does something like this exist, in the standard library or elsewhere, or is an if-else ladder the only way to achieve any type of "pattern matching"?
