Error Handling and std::optional

In my last two posts in the C++17 STL series, I covered how to use std::optional. This wrapper type (also called “vocabulary type") is handy when you’d like to express that something is ‘nullable’ and might be ’empty.’ For example, you can return std::nullopt to indicate that the code generated an error… but it this the best choice?
What’s the Problem?
Let’s see an example:

Link: https://dzone.com/articles/error-handling-and-stdoptional?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev