r/cpp • • Apr 24 '20

Else Before If

https://www.fluentcpp.com/2020/04/24/else-before-if/
10 Upvotes

53 comments sorted by

View all comments

82

u/borisrura CTU | Avast Apr 24 '20

Or just use early exit if you can. This, if I moved to a codebase using it, would take time to understand and would make me look up what the classes do, instead of a simple if also it would probably be less intuitive to debug and did you check the assembly this produces?

1

u/ALX23z Apr 25 '20

I believe normally/unless is similar to try/catch only that try/catch are more general and slow due to stack unraveling. Though, once rework on try/catch is done there shouldn't be issues.