[libcxx-commits] [PATCH] D140911: [In Progress][libc++] Implement P2505R5(Monadic operations for std::expected)

Yurong via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 8 04:19:13 PST 2023


yronglin added inline comments.


================
Comment at: libcxx/include/__expected/expected.h:1313
+  requires is_copy_constructible_v<_Err> _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & {
+    using _Up = remove_cv_t<invoke_result_t<_Func>>;
+    if (has_value()) {
----------------
Do we need to add a static_assert to check `the declaration U u(invoke(std::forward<F>(f), value())); is well-formed.`?
```
Mandates: U is a valid value type for expected.
If is_­void_­v<U> is false, the declaration U u(invoke(std::forward<F>(f), value()));
is well-formed.
```
for example:
```
using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&>>;
static_assert(__expected::__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); // I'll and this
static_assert(is_constructible_v<_Up, invoke_result_t<_Func, const _Tp&>>, "The result of f(value()) must be copy constructible"); // looks a bit redundant
```
what do you think about?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140911/new/

https://reviews.llvm.org/D140911



More information about the libcxx-commits mailing list