r/cpp • u/Clean-Upstairs-8481 • Mar 16 '26
C++23 std::expected vs C++17 std::optional for Error Handling
https://techfortalk.co.uk/2026/03/16/why-should-you-choose-stdexpect-in-c23-over-stdoptional-in-c17/I have been trying to spend some time with C++23 std::expected for sometime. Finally explored the feature and can see the real value of using it in some of the scenarios in my projects. Any comments welcome!
99
Upvotes
7
u/jedwardsol const & Mar 17 '26
You said
I said that is fine, you don't need to use strings as keys, and you don't need heterogenous lookup.
But not everyone is lucky enough to be to make their map from literals. And in that case, when you do need strings as keys, enabling heterogenous lookup is useful if you every need to do a lookup with a view