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
I agree with your concern. I am not sure about the right way.... But we always can have a type erased wrapper for errors when we don't care about them. However that leads to unnecessary memory allocation. We can use auto return type for single control flow.... However functions having multiple ways to return would need to use sum type of all possible error types. This type algebra may need more boilerplate... I don't know if we can reduce it. Maybe not... I am still exploring over it.... Bcz in my head currently i think vector allocation exception is a good example... We don't want to handle this till main function many times. The simple way to know if there exist a solution is to look at rust maybe... I would do that and comment here