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