[libcxx-commits] [PATCH] D94452: [libc++] Support immovable return types in std::function.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 21 11:52:14 PST 2021

ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.

Comment at: libcxx/include/__functional_base:343
+template <class _Ret>
+struct __invoke_void_return_wrapper<_Ret, true>
I don't understand why this change is necessary. Can you explain?

Comment at: libcxx/include/functional:2352
+            static const bool value = is_void<_Rp>::value ||
+                __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type,
+                                      _Rp>::value;
Can you explain why we can't use `std::is_convertible`? Is it possible that it's simply a bug in how we implement the `__is_convertible` intrinsic?

Comment at: libcxx/include/type_traits:1673
+// to a function. Notice that __is_core_convertible<void,void> is false,
+// and __is_core_convertible<mutex,mutex> is true in C++17 and later.
`mutex`? Do you mean `any-non-moveable-type`? If so, please use that in the example as it's clearer.

Comment at: libcxx/include/type_traits:1680
+struct __is_core_convertible<_Tp, _Up, decltype(
+    static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() )
+)> : public true_type {};
Can't you use `declval` here?

Comment at: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/noncopyable_return_type.pass.cpp:8
+// UNSUPPORTED: c++03, c++11, c++14
`// ADDITIONAL_COMPILE_FLAGS: -Wno-ignored-qualifiers`

Nifty trick. Also please add a short comment explaining why you're turning that warning off.

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list