Rust has a ? operator for error propagation without exceptions. When a function returns a Result or Option type, one can write:
let a = get_a()?;
Which effectively means:
let _a = get_a();
let mut a = match _a {
Ok(value) => value,
Err(e) => return Err(e),
}
Or, in other words, if the returned value contains an error, the function will return and propagate the error. All of this happens in just one char, so the code is compact without too many if (err) return err branches.
Same concept exists in C#: Null-conditional operators
In C++, the closest thing I was able to find is tl::expected and Boost.outcome. But those two require use of e. g. lambdas to achieve same thing and it's not as concise. From what I understand, affecting control flow like that would require some kind of language feature or extension.
I tried to find a proposal that would implement it or be related at least and couldn't. Is there a C++ proposal for implementing it?