Functional exception-less error handling with C++23’s optional and expected -- Sy Brand
std::optional has been updated in C++23, and std::expected added as a new way of representing errors in your code. Read more about them here:
Functional exception-less error handling with C++23’s optional and expected
by Sy Brand
From the article:
std::optional<T> expresses “either a T or nothing”. C++23 comes with a new type, std::expected<T,E> which expresses “either the expected T, or some E telling you what went wrong”. This type also comes with that special new functional interface. As of Visual Studio 2022 version 17.6 Preview 3, all of these features are available in our standard library. Armed with an STL implementation you can try yourself, I’m going to exhibit how to use std::optional‘s new interface, and the new std::expected to handle disappointments.