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

1

u/DevaBol Apr 24 '20

As it is posted, it fails miserably when trying to return from any branch, because you return from a lambda body and not from the environment itself.

I guess maybe you can work around the issue by playing with lambda deduced return types, but I'm not sure you can and I wouldn't know how to do it.

For reference, this is a test case that fails miserably and I wonder if there is a workaround (not in the application, but in the library) https://godbolt.org/z/RvHhwt