fenbf / cppstories-discussions

4 stars 1 forks source link

2024/expected-cpp23-internals/ #147

Open utterances-bot opened 1 month ago

utterances-bot commented 1 month ago

Understand internals of std::expected - C++ Stories

In the article about std::expected, I introduced the type and showed some basic examples, and in this text, you’ll learn how it is implemented. A simple idea with struct   In short, std::expected should contain two data members: the actual expected value and the unexpected error object. So, in theory, we could use a simple structure:

https://www.cppstories.com/2024/expected-cpp23-internals/

mguludag commented 1 month ago

I tried to extend the expected class with multiple unexpected types using std::variant. Decide the return type and behavior of some monadic functions a bit harder to me but finally finished it https://github.com/mguludag/expected