Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:37

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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 // Helpful to provide better error messages. This will show the algorithm and the execution policy
0039 // in the compiler diagnostic.
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 } // namespace __pstl
0062 _LIBCPP_END_NAMESPACE_STD
0063 
0064 _LIBCPP_POP_MACROS
0065 
0066 #endif // _LIBCPP___CXX03___PSTL_DISPATCH_H