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:| C++ Stories
In this post we’ll have a look at new operations added to std::optional in C++23. These operations, inspired by functional programming concepts, offer a more concise and expressive way to work with optional values, reducing boilerplate and improving code readability. Let’s meet and_then(), transform() and or_else(), new member functions. Traditional Approach with if/else and optional C++20 In C++20 when you work with std::optional you have to rely heavily on conditional checks to ensur...| C++ Stories