Skip to content

[libc][NFC] Fix accessor qualifiers for cpp::expected #80424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 3, 2024

Conversation

gchatelet
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 2, 2024

@llvm/pr-subscribers-libc

Author: Guillaume Chatelet (gchatelet)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/80424.diff

1 Files Affected:

  • (modified) libc/src/__support/CPP/expected.h (+5-3)
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; }
 

@gchatelet gchatelet merged commit cca3db9 into llvm:main Feb 3, 2024
@gchatelet gchatelet deleted the fix_expected branch February 3, 2024 11:15
agozillon pushed a commit to agozillon/llvm-project that referenced this pull request Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants