[libcxx-commits] [PATCH] D124516: [libc++] Implement `std::expected` P0323R12
Eric Fiselier via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 1 16:59:50 PDT 2022
EricWF added inline comments.
================
Comment at: libcxx/include/__expected/expected.h:927
+ } else {
+ return __x.has_value() || static_cast<bool>(__x.error() == __y.error());
+ }
----------------
Oh god, we can compare error types for equality that don't produce a boolean output. That's terrifying. I assume that's what the standard wants, but that's terrifying.
================
Comment at: libcxx/include/__expected/expected.h:933
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) {
+ return !__x.has_value() && static_cast<bool>(__x.error() == __y.error());
+ }
----------------
You can avoid the function calls by touching the members directly. That'll save in non-optimized build size.
================
Comment at: libcxx/include/__expected/expected.h:937
+private:
+ bool __has_val_;
+ union {
----------------
Reverse the order of these members please.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124516/new/
https://reviews.llvm.org/D124516
More information about the libcxx-commits
mailing list