4 ms·
Typo: in the user code example, I think the second should be in rather than out. This is pretty cute - looks useful in practice. I think you can slightly enha
by comex 11y ago
Typo: in the user code example, I think the second should be in rather than out.
This is pretty cute - looks useful in practice. I think you can slightly enhance the probability of the compiler making the result efficient by using a switch statement, like:
goto setup1;
got_value:
switch (value) {
setup1: ...setup 1...; goto setup2;
case 1: ...; break;
}
etc.
In C++, you could do something fairly equivalent with lambdas, without having to involve the "evil" preprocessor.
- rumcajz 11y agoUh, fixed. Your solution looks a lot like Duff's device :)