File indexing completed on 2026-05-03 08:13:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___PSTL_DISPATCH_H
0010 #define _LIBCPP___PSTL_DISPATCH_H
0011
0012 #include <__config>
0013 #include <__pstl/backend_fwd.h>
0014 #include <__type_traits/conditional.h>
0015 #include <__type_traits/enable_if.h>
0016 #include <__type_traits/integral_constant.h>
0017 #include <__type_traits/type_identity.h>
0018
0019 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0020 # pragma GCC system_header
0021 #endif
0022
0023 _LIBCPP_PUSH_MACROS
0024 #include <__undef_macros>
0025
0026 #if _LIBCPP_STD_VER >= 17
0027
0028 _LIBCPP_BEGIN_NAMESPACE_STD
0029 namespace __pstl {
0030
0031 template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy, class = void>
0032 constexpr bool __is_implemented_v = false;
0033
0034 template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy>
0035 constexpr bool __is_implemented_v<_Algorithm,
0036 _Backend,
0037 _ExecutionPolicy,
0038 __enable_if_t<sizeof(_Algorithm<_Backend, _ExecutionPolicy>)>> = true;
0039
0040
0041
0042 template <template <class, class> class _Algorithm, class _ExecutionPolicy>
0043 constexpr bool __cant_find_backend_for = false;
0044
0045 template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
0046 struct __find_first_implemented;
0047
0048 template <template <class, class> class _Algorithm, class _ExecutionPolicy>
0049 struct __find_first_implemented<_Algorithm, __backend_configuration<>, _ExecutionPolicy> {
0050 static_assert(__cant_find_backend_for<_Algorithm, _ExecutionPolicy>,
0051 "Could not find a PSTL backend for the given algorithm and execution policy");
0052 };
0053
0054 template <template <class, class> class _Algorithm, class _B1, class... _Bn, class _ExecutionPolicy>
0055 struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>, _ExecutionPolicy>
0056 : _If<__is_implemented_v<_Algorithm, _B1, _ExecutionPolicy>,
0057 __type_identity<_Algorithm<_B1, _ExecutionPolicy>>,
0058 __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {};
0059
0060 template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
0061 using __dispatch _LIBCPP_NODEBUG =
0062 typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type;
0063
0064 }
0065 _LIBCPP_END_NAMESPACE_STD
0066
0067 #endif
0068
0069 _LIBCPP_POP_MACROS
0070
0071 #endif