[libc-commits] [libc] [libc][NFC] Fix accessor qualifiers for `cpp::expected` (PR #80424)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Fri Feb 2 04:39:35 PST 2024
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/80424
None
>From e8c924ce45ab8639715a987d6a2b563f975b068f Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Fri, 2 Feb 2024 12:39:12 +0000
Subject: [PATCH] [libc][NFC] Fix accessor qualifiers for `cpp::expected`
---
libc/src/__support/CPP/expected.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libc/src/__support/CPP/expected.h b/libc/src/__support/CPP/expected.h
index 52174a054f874..100abfc221161 100644
--- a/libc/src/__support/CPP/expected.h
+++ b/libc/src/__support/CPP/expected.h
@@ -33,10 +33,12 @@ template <class T, class E> class expected {
constexpr expected(unexpected<E> 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; }
More information about the libc-commits
mailing list