4 ms·
>For instance if you are sure that a switch-case default branch is actually unreachable you can put a std::unreachable into the default-branch to hint the compi
by dailykoder 2y ago
>For instance if you are sure that a switch-case default branch is actually unreachable you can put a std::unreachable into the default-branch to hint the compiler that it may remove a range check in front of the switch-case jump table access
I guess they stole this idea from Terry Davis who implemented this in holyC. When you use square brackets it just doesn't do any range check. Terry, as always, been ahead of the times. Like so:
switch[abc] { [...] }
- flohofwoe 2y agoTbf it's a fairly obvious idea when looking at the compiler output for a large switch-case statement.