Skip to content

Commit cca3db9

Browse files
authored
[libc][NFC] Fix accessor qualifiers for cpp::expected (#80424)
1 parent d9850fe commit cca3db9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libc/src/__support/CPP/expected.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ template <class T, class E> class expected {
3333
constexpr expected(unexpected<E> unexp)
3434
: unexp(unexp.error()), is_expected(false) {}
3535

36-
constexpr bool has_value() { return is_expected; }
36+
constexpr bool has_value() const { return is_expected; }
3737

38-
constexpr T value() { return exp; }
39-
constexpr E error() { return unexp; }
38+
constexpr T &value() { return exp; }
39+
constexpr E &error() { return unexp; }
40+
constexpr const T &value() const { return exp; }
41+
constexpr const E &error() const { return unexp; }
4042

41-
constexpr operator bool() { return is_expected; }
43+
constexpr operator bool() const { return is_expected; }
4244

4345
constexpr T &operator*() { return exp; }
4446
constexpr const T &operator*() const { return exp; }

0 commit comments

Comments
 (0)