[libcxx-commits] [PATCH] D154116: [libc++] Implement LWG3938 (Cannot use std::expected monadic ops with move-only error_type)
A. Jiang via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 23 20:16:43 PDT 2023
frederick-vs-ja added a comment.
In D154116#4490038 <https://reviews.llvm.org/D154116#4490038>, @yronglin wrote:
> @Mordante Can we propose to use `__union_.__val_`, `std::as_const(__union_.__val_)`, `std::move(__union_.__val_)` and `std::move(std::as_const(__union_.__val_))` instead of `**this` ?
`std::as_const` is unnecessary because the `const` on the member functions already makes `__union_.__val_` a const lvalue.
I think it's better to use the member access expressions instead of `**this`, because the latter can be ADL-hijacked. (However, this means the current standard wording is less than ideal and an LWG issue may be needed, see also LWG3969 <https://cplusplus.github.io/LWG/issue3969>).
================
Comment at: libcxx/include/__expected/expected.h:643
using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;
static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected");
static_assert(is_same_v<typename _Up::error_type, _Err>,
----------------
It might be better to update the messages in `static_assert` (also occurs below; I originally suggested [[ https://github.com/cplusplus/draft/issues/6500#issuecomment-1689123585 | here ]].).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154116/new/
https://reviews.llvm.org/D154116
More information about the libcxx-commits
mailing list