]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/libcxx/include/__algorithm/pstl_frontend_dispatch.h
Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51
[FreeBSD/FreeBSD.git] / contrib / llvm-project / libcxx / include / __algorithm / pstl_frontend_dispatch.h
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH
10 #define _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH
11
12 #include <__config>
13 #include <__type_traits/is_callable.h>
14 #include <__utility/forward.h>
15
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #  pragma GCC system_header
18 #endif
19
20 #if _LIBCPP_STD_VER >= 17
21
22 _LIBCPP_BEGIN_NAMESPACE_STD
23
24 #  define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name)                                                                       \
25     [](auto&&... __args) -> decltype(std::name<_RawPolicy>(typename __select_backend<_RawPolicy>::type{},              \
26                                                            std::forward<decltype(__args)>(__args)...)) {               \
27       return std::name<_RawPolicy>(                                                                                    \
28           typename __select_backend<_RawPolicy>::type{}, std::forward<decltype(__args)>(__args)...);                   \
29     }
30
31 template <class _SpecializedImpl, class _GenericImpl, class... _Args>
32 _LIBCPP_HIDE_FROM_ABI decltype(auto)
33 __pstl_frontend_dispatch(_SpecializedImpl __specialized_impl, _GenericImpl __generic_impl, _Args&&... __args) {
34   if constexpr (__is_callable<_SpecializedImpl, _Args...>::value) {
35     return __specialized_impl(std::forward<_Args>(__args)...);
36   } else {
37     return __generic_impl(std::forward<_Args>(__args)...);
38   }
39 }
40
41 _LIBCPP_END_NAMESPACE_STD
42
43 #endif // _LIBCPP_STD_VER >= 17
44
45 #endif // _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH