Path: blob/main/contrib/llvm-project/libcxx/include/__pstl/dispatch.h
35233 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___PSTL_DISPATCH_H9#define _LIBCPP___PSTL_DISPATCH_H1011#include <__config>12#include <__pstl/backend_fwd.h>13#include <__type_traits/conditional.h>14#include <__type_traits/enable_if.h>15#include <__type_traits/integral_constant.h>16#include <__type_traits/type_identity.h>1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19# pragma GCC system_header20#endif2122_LIBCPP_PUSH_MACROS23#include <__undef_macros>2425_LIBCPP_BEGIN_NAMESPACE_STD26namespace __pstl {2728template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy, class = void>29constexpr bool __is_implemented_v = false;3031template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy>32constexpr bool __is_implemented_v<_Algorithm,33_Backend,34_ExecutionPolicy,35__enable_if_t<sizeof(_Algorithm<_Backend, _ExecutionPolicy>)>> = true;3637// Helpful to provide better error messages. This will show the algorithm and the execution policy38// in the compiler diagnostic.39template <template <class, class> class _Algorithm, class _ExecutionPolicy>40constexpr bool __cant_find_backend_for = false;4142template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>43struct __find_first_implemented;4445template <template <class, class> class _Algorithm, class _ExecutionPolicy>46struct __find_first_implemented<_Algorithm, __backend_configuration<>, _ExecutionPolicy> {47static_assert(__cant_find_backend_for<_Algorithm, _ExecutionPolicy>,48"Could not find a PSTL backend for the given algorithm and execution policy");49};5051template <template <class, class> class _Algorithm, class _B1, class... _Bn, class _ExecutionPolicy>52struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>, _ExecutionPolicy>53: _If<__is_implemented_v<_Algorithm, _B1, _ExecutionPolicy>,54__type_identity<_Algorithm<_B1, _ExecutionPolicy>>,55__find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {};5657template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>58using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type;5960} // namespace __pstl61_LIBCPP_END_NAMESPACE_STD6263_LIBCPP_POP_MACROS6465#endif // _LIBCPP___PSTL_DISPATCH_H666768