Hacker News new | past | comments | ask | show | jobs | submit login

I'm surprised nobody mentioned co_await yet. This should be possible.

std::optional<int> foo();

And then

std::optional<int> bar(){

   int x = co_await foo();

   int y = co_await foo();

   return x+y;
}

No messy chaining or lambda pyramid of doom.

I'm surprised that the monadic ops and C++ co_await are not being aligned in the standard yet




It is doable, `folly::Expected` supports that: https://github.com/facebook/folly/blob/main/folly/test/Expec...


I'll have to check that out. Thanks




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: