[libcxx-commits] [libcxx] [libc++] Avoid using **this to access the value stored in std::expected (PR #84840)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 18 07:36:07 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");
----------------
philnik777 wrote:

Maybe we could just say something like "The result type of the functor must be a specialization of std::expected"? Most people will probably just have a lambda for it anyways. @cjdb might also have thoughts on how to word this.

https://github.com/llvm/llvm-project/pull/84840


More information about the libcxx-commits mailing list