Honestly, it's not. I really pushed it and this solution is actually undefined behaviour since the lambdas are not regular invocable.
But I do think that from a software engineering perspective, moving to ugly functional code will be a good move. Simply because it makes static analysis so much more powerful.
I wish we could write beautiful functional code in C++, but I don't think that will ever happen :-D
It's an unreadable mess. I do not for the life of me understand why people have an issue with seeing a for or while loop. They think it is bad code for some reason which is just bizarre to me. It's far easier to read and shows you *what is actually happening*. It is much better than code compressed into chained, filthy functional bollocks.
IMO it may be more readable for a C++ dev that regularly works with this kind of syntax. For everybody else, no, a loop & if is more readable, if you ask me. Opinions may differ.
7
u/[deleted] Dec 15 '21
Honestly, it's not. I really pushed it and this solution is actually undefined behaviour since the lambdas are not regular invocable.
But I do think that from a software engineering perspective, moving to ugly functional code will be a good move. Simply because it makes static analysis so much more powerful.
I wish we could write beautiful functional code in C++, but I don't think that will ever happen :-D