C++23 std::expected vs C++17 std::optional for Error Handling
C++17 introduced std::optional to improve API design by allowing functions to return an optional value. Instead of returning a placeholder like -1 when a key isn’t found in a map, std::optional lets functions return std::nullopt. C++23 further enhances error handling with std::expected, allowing custom error messages.