Some time ago I have shown a real life example of the reason for the existence of generic lambda, which I managed to make.
Now please consider this:
1 2 3 4 5 6 7 8 9 10 |
/* recursive generic lambda */ auto summa = [](auto first, auto ... second) { if constexpr (sizeof ... (second) > 0) { return first + summa(second ...); } else { return first; } }; |
This is not a toy. I also use it in my previous post. For me, this is the celebration of standard C++. But.
Make no mistake. There are still numerous people who consider this kind of code the epitome of the end of C++. They are hotly against Functional Programming (FP). And hotly against the auto
keyword. And hotly against whatever they can think of on a given (hot) day in some forum.
I have really nothing against them, but I have to think these are the people forever searching for the “c++ killer”; the people who were the first jumping from the C++11/14/17 “lunacy” onto the (for example) D bandwagon, and then again jumping from that bandwagon nack to the C++ wagon, when D turned out to be a “slow train crash“.
Now they are probably considering “Rust“. Until they make a full circle back to the standard C++ bandwagon, again.
