1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH
10 #define _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH
13 #include <__type_traits/is_callable.h>
14 #include <__utility/forward.h>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
20 #if _LIBCPP_STD_VER >= 17
22 _LIBCPP_BEGIN_NAMESPACE_STD
24 # define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name, policy) \
25 [](auto&&... __args) -> decltype(std::name<policy>( \
26 typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...)) { \
27 return std::name<policy>(typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...); \
30 template <class _SpecializedImpl
, class _GenericImpl
, class... _Args
>
31 _LIBCPP_HIDE_FROM_ABI
decltype(auto)
32 __pstl_frontend_dispatch(_SpecializedImpl __specialized_impl
, _GenericImpl __generic_impl
, _Args
&&... __args
) {
33 if constexpr (__is_callable
<_SpecializedImpl
, _Args
...>::value
) {
34 return __specialized_impl(std::forward
<_Args
>(__args
)...);
36 return __generic_impl(std::forward
<_Args
>(__args
)...);
40 _LIBCPP_END_NAMESPACE_STD
42 #endif // _LIBCPP_STD_VER >= 17
44 #endif // _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH