[libcxx-commits] [libcxx] [libc++] Implement LWG3476: Add mandates to thread, jthread, and async (PR #173363)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 23 17:32:39 PST 2025


================
@@ -1847,15 +1849,20 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch
 template <class _Fp, class... _Args>
 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> >
 async(launch __policy, _Fp&& __f, _Args&&... __args) {
+#      if _LIBCPP_STD_VER >= 17
+  static_assert(is_constructible_v<__decay_t<_Fp>, _Fp>);
+  static_assert((is_constructible_v<__decay_t<_Args>, _Args> && ...));
+  static_assert(is_invocable_v<__decay_t<_Fp>, __decay_t<_Args>...>);
+#      endif
----------------
frederick-vs-ja wrote:

Let's also backport them in `async`.
```suggestion
  static_assert(is_constructible<__decay_t<_Fp>, _Fp>::value, "");
  static_assert(_And<is_constructible<__decay_t<_Args>, _Args>...>::value, "");
  static_assert(__is_invocable_v<__decay_t<_Fp>, __decay_t<_Args>...>, "");
```

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


More information about the libcxx-commits mailing list