diff --git a/libc/src/__support/CPP/expected.h b/libc/src/__support/CPP/expected.h index 52174a054f874..9682de981a834 100644 --- a/libc/src/__support/CPP/expected.h +++ b/libc/src/__support/CPP/expected.h @@ -33,12 +33,14 @@ template class expected { constexpr expected(unexpected unexp) : unexp(unexp.error()), is_expected(false) {} - constexpr bool has_value() { return is_expected; } + constexpr bool has_value() const { return is_expected; } - constexpr T value() { return exp; } - constexpr E error() { return unexp; } + constexpr T &value() { return exp; } + constexpr E &error() { return unexp; } + constexpr const T &value() const { return exp; } + constexpr const E &error() const { return unexp; } - constexpr operator bool() { return is_expected; } + constexpr operator bool() const { return is_expected; } constexpr T &operator*() { return exp; } constexpr const T &operator*() const { return exp; }