C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A draft for modern switch

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sat, 31 May 2025 12:33:23 +0200
None of the compilers seems to handle that code well: Creating just a comparison, whether the string has one letter between 'a' and 'n' and outputting that letter with a newline. -----Ursprüngliche Nachricht----- Von:Zhao YunShan via Std-Proposals <std-proposals_at_[hidden]> I wrote a piece of code equivalent to `switch (string)`, using an `if...else if... chains` structure, as shown here: https://gcc.godbolt.org/z/bf61o41M6 It appears that the compiler uses a "jump table" and does not employ a "multiway branch", which is interesting.

Received on 2025-05-31 10:41:17