[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __pstl / dispatch.h
blobea40fa79eb9496cd4053dd802b936dd8e5e0cb94
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 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___PSTL_DISPATCH_H
10 #define _LIBCPP___PSTL_DISPATCH_H
12 #include <__config>
13 #include <__pstl/backend_fwd.h>
14 #include <__type_traits/conditional.h>
15 #include <__type_traits/enable_if.h>
16 #include <__type_traits/integral_constant.h>
17 #include <__type_traits/type_identity.h>
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 # pragma GCC system_header
21 #endif
23 _LIBCPP_PUSH_MACROS
24 #include <__undef_macros>
26 #if _LIBCPP_STD_VER >= 17
28 _LIBCPP_BEGIN_NAMESPACE_STD
29 namespace __pstl {
31 template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy, class = void>
32 constexpr bool __is_implemented_v = false;
34 template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy>
35 constexpr bool __is_implemented_v<_Algorithm,
36 _Backend,
37 _ExecutionPolicy,
38 __enable_if_t<sizeof(_Algorithm<_Backend, _ExecutionPolicy>)>> = true;
40 // Helpful to provide better error messages. This will show the algorithm and the execution policy
41 // in the compiler diagnostic.
42 template <template <class, class> class _Algorithm, class _ExecutionPolicy>
43 constexpr bool __cant_find_backend_for = false;
45 template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
46 struct __find_first_implemented;
48 template <template <class, class> class _Algorithm, class _ExecutionPolicy>
49 struct __find_first_implemented<_Algorithm, __backend_configuration<>, _ExecutionPolicy> {
50 static_assert(__cant_find_backend_for<_Algorithm, _ExecutionPolicy>,
51 "Could not find a PSTL backend for the given algorithm and execution policy");
54 template <template <class, class> class _Algorithm, class _B1, class... _Bn, class _ExecutionPolicy>
55 struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>, _ExecutionPolicy>
56 : _If<__is_implemented_v<_Algorithm, _B1, _ExecutionPolicy>,
57 __type_identity<_Algorithm<_B1, _ExecutionPolicy>>,
58 __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {};
60 template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
61 using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type;
63 } // namespace __pstl
64 _LIBCPP_END_NAMESPACE_STD
66 #endif // _LIBCPP_STD_VER >= 17
68 _LIBCPP_POP_MACROS
70 #endif // _LIBCPP___PSTL_DISPATCH_H