Index: include/execution =================================================================== --- /dev/null +++ include/execution @@ -0,0 +1,67 @@ +// -*- C++ -*- +//===-------------------------- execution ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXECUTION +#define _LIBCPP_EXECUTION + +/* + execution synopsis + +namespace std +{ + +template struct is_execution_policy; +template inline constexpr bool is_execution_policy_v + = is_execution_policy::value; + +namespace execution +{ + + class sequenced_policy; + class parallel_policy; + class parallel_unsequenced_policy; + class unsequenced_policy; + + inline constexpr sequenced_policy seq; + inline constexpr parallel_policy par; + inline constexpr parallel_unsequenced_policy par_unseq; + inline constexpr unsequenced_policy unseq; +} + +} + +*/ + +#include + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace execution +{ + class __policy_type { }; + + class sequenced_policy : __policy_type { }; + class parallel_policy : __policy_type { }; + class parallel_unsequenced_policy : __policy_type { }; + class unsequenced_policy : __policy_type { }; + + inline constexpr sequenced_policy seq; + inline constexpr parallel_policy par; + inline constexpr parallel_unsequenced_policy par_unseq; + inline constexpr unsequenced_policy unseq; +} + +template +struct is_execution_policy: is_base_of { }; +template +inline constexpr bool is_execution_policy_v = is_execution_policy<_Tp>::value; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_EXECUTION Index: test/std/algorithms/algorithms.parallel.exec/execution_policy.pass.cpp =================================================================== --- /dev/null +++ test/std/algorithms/algorithms.parallel.exec/execution_policy.pass.cpp @@ -0,0 +1,37 @@ +#include +#include + +class not_ep_c { }; +struct not_ep_s { }; + +template +void assert_is_execution_policy() +{ static_assert(std::is_execution_policy::value, ""); } + +int main() +{ + assert_is_execution_policy(); + assert_is_execution_policy(); + assert_is_execution_policy(); + assert_is_execution_policy(); + + assert_is_execution_policy(); + assert_is_execution_policy(); + assert_is_execution_policy(); + assert_is_execution_policy(); + + static_assert(std::is_convertible::value, ""); + static_assert(std::is_convertible::value, ""); + static_assert(std::is_convertible::value, ""); + static_assert(std::is_convertible::value, ""); + + static_assert(!std::is_execution_policy::value, ""); + static_assert(!std::is_execution_policy::value, ""); + static_assert(!std::is_execution_policy::value, ""); + + return 0; +} \ No newline at end of file