[libcxx-commits] [libcxx] c25c22d - [libcxx] moves `std::invoke` into `__functional_base`

Christopher Di Bella via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 5 18:45:48 PDT 2021


Author: Christopher Di Bella
Date: 2021-04-06T01:25:15Z
New Revision: c25c22d5f9b7e56c0c350982b5ec41095c5a0a05

URL: https://github.com/llvm/llvm-project/commit/c25c22d5f9b7e56c0c350982b5ec41095c5a0a05
DIFF: https://github.com/llvm/llvm-project/commit/c25c22d5f9b7e56c0c350982b5ec41095c5a0a05.diff

LOG: [libcxx] moves `std::invoke` into `__functional_base`

Including `<concepts>` in other standard library headers (such as
`<iterator>`) creates circular dependencies due to `<functional>`.
Since `<concepts>` only needs `std::invoke` from `<functional>`, the
easiest, fastest, and cleanest way to eliminate the circular dep is to
move `std::invoke` into `__functional_base`.

This has the added advantage of `<concepts>` not transitively importing
`<functional>`.

Differential Revision: https://reviews.llvm.org/D99041

Added: 
    

Modified: 
    libcxx/include/__functional_base
    libcxx/include/concepts
    libcxx/include/functional

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base
index caa746036bf5e..5e98eba96a64c 100644
--- a/libcxx/include/__functional_base
+++ b/libcxx/include/__functional_base
@@ -665,6 +665,18 @@ void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, con
 
 #endif  // _LIBCPP_CXX03_LANG
 
+#if _LIBCPP_STD_VER > 14
+
+template <class _Fn, class ..._Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
+invoke(_Fn&& __f, _Args&&... __args)
+    noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
+{
+    return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_FUNCTIONAL_BASE

diff  --git a/libcxx/include/concepts b/libcxx/include/concepts
index 0a3e9278ea51e..070e1df64d193 100644
--- a/libcxx/include/concepts
+++ b/libcxx/include/concepts
@@ -135,7 +135,7 @@ namespace std {
 */
 
 #include <__config>
-#include <functional>
+#include <__functional_base>
 #include <type_traits>
 #include <utility>
 #include <version>

diff  --git a/libcxx/include/functional b/libcxx/include/functional
index e5b85c2bde8df..bbc2301b6c33a 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -2986,14 +2986,6 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
 
 #if _LIBCPP_STD_VER > 14
 
-template <class _Fn, class ..._Args>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
-invoke(_Fn&& __f, _Args&&... __args)
-    noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
-{
-    return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
-}
-
 template<class _Op, class _Tuple,
          class _Idxs = typename __make_tuple_indices<tuple_size<_Tuple>::value>::type>
 struct __perfect_forward_impl;


        


More information about the libcxx-commits mailing list