[libcxx-commits] [libcxx] [libc++] Avoid using **this to access the value stored in std::expected (PR #84840)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 14 23:27:20 PDT 2024
================
@@ -920,9 +920,9 @@ class expected : private __expected_base<_Tp, _Err> {
requires is_constructible_v<_Err, _Err&>
_LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;
- static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected");
+ static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected");
----------------
frederick-vs-ja wrote:
This may be a bit misleading as `value()` can be ill-formed (because the error type is not copyable) while monadic operations being well-formed. See also [LWG3938](https://cplusplus.github.io/LWG/issue3938) and [LWG3940](https://cplusplus.github.io/LWG/issue3940).
The resolution of [LWG3973](https://cplusplus.github.io/LWG/issue3973) uses _`val`_ (exposition-only member name). Perhaps we can use `val` or `__val()` (libc++-specific function name) in the error messages instead.
https://github.com/llvm/llvm-project/pull/84840
More information about the libcxx-commits
mailing list