[libc-commits] [libc] [libc][NFC] Fix accessor qualifiers for `cpp::expected` (PR #80424)
via libc-commits
libc-commits at lists.llvm.org
Fri Feb 2 04:40:13 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Guillaume Chatelet (gchatelet)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/80424.diff
1 Files Affected:
- (modified) libc/src/__support/CPP/expected.h (+5-3)
``````````diff
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; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/80424
More information about the libc-commits
mailing list