diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -10,6 +10,7 @@ __functional_base __functional_base_03 __hash_table + __invoke __libcpp_version __locale __memory/allocator_traits.h diff --git a/libcxx/include/__invoke b/libcxx/include/__invoke new file mode 100644 --- /dev/null +++ b/libcxx/include/__invoke @@ -0,0 +1,43 @@ + +// -*- C++ -*- +//===------------------------ functional ----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_INVOKE +#define _LIBCPP_INVOKE + +#include <__config> +#include <__functional_base> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template +_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 + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP_INVOKE diff --git a/libcxx/include/concepts b/libcxx/include/concepts --- a/libcxx/include/concepts +++ b/libcxx/include/concepts @@ -135,7 +135,7 @@ */ #include <__config> -#include +#include <__invoke> #include #include #include diff --git a/libcxx/include/functional b/libcxx/include/functional --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -514,6 +514,7 @@ #include #include <__functional_base> +#include <__invoke> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -2984,14 +2985,6 @@ #if _LIBCPP_STD_VER > 14 -template -_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::value>::type> struct __perfect_forward_impl; diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -532,6 +532,7 @@ module __errc { header "__errc" export * } module __functional_base { header "__functional_base" export * } module __hash_table { header "__hash_table" export * } + module __invoke { header "__invoke" export * } module __locale { header "__locale" export * } module __mutex_base { header "__mutex_base" export * } module __split_buffer { header "__split_buffer" export * }