C++ Logo

std-proposals

Advanced search

[std-proposals] std::expected

From: Rhidian De Wit <rhidiandewit_at_[hidden]>
Date: Sat, 30 Aug 2025 14:47:36 +0200
Hi all,

I've recently started using *std::expected* as I'm a fan of the idea of
getting better error-types without needing to resort to integer-return
types or exceptions.
However, I find *std::expected* quite cumbersome to use, primarily because
I always need to check *has_value()* before safely accessing *value()*
Rust's *Result* (almost 1:1 with C++'s *std::expected*) type provides the
*?* operator to easily grab the contained value, or propagate the error to
the callee if the *Result* type contains an error.
Is there a proposal to add similar functionality to C++'s *std::expected*?
I think this is something that would greatly benefit the current
*std::expected* implementation.

Thanks in advance!

-- 
Rhidian De Wit
Software Engineer - Barco

Received on 2025-08-30 12:47:48