[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
This commit is contained in:
Christopher Di Bella 2021-03-21 18:48:24 +00:00
parent dc8d864e3a
commit c25c22d5f9
3 changed files with 13 additions and 9 deletions

View File

@ -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

View File

@ -135,7 +135,7 @@ namespace std {
*/
#include <__config>
#include <functional>
#include <__functional_base>
#include <type_traits>
#include <utility>
#include <version>

View File

@ -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;