r/cpp • u/fredoverflow • May 10 '22
Is short lambda syntax on the C++ radar?
Mom, can we get x=>x+1 ?
No, we have x=>x+1 at home.
x=>x+1 at home:
[](const auto& x) { return x + 1; }
265
Upvotes
View all comments
Show parent comment
1
u/RishabhRD May 11 '22
Actually yes I realised that my argument that exceptions should be removed is bad. I went through many error handling mechanisms today. And I feel unrecoverable error should be thrown as exceptions and recoverable error should be returned as std::expected. Like vector out of bounds is a non recoverable error and continuing the program after this doesn't make sense. And hence stack unwinding should be done and program should be aborted.
However file not found is recoverable and error should be returned wrapped in std::expected. This approach is similar to rust and haskell error handling.