Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/execution
// -*- C++ -*- | // -*- C++ -*- | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef _LIBCPP_EXECUTION | #ifndef _LIBCPP_EXECUTION | ||||
#define _LIBCPP_EXECUTION | #define _LIBCPP_EXECUTION | ||||
#include <__assert> // all public C++ headers provide the assertion handler | #include <__assert> // all public C++ headers provide the assertion handler | ||||
#include <__config> | #include <__config> | ||||
#include <__type_traits/integral_constant.h> | #include <__type_traits/integral_constant.h> | ||||
#include <__type_traits/is_execution_policy.h> | |||||
#include <__type_traits/is_same.h> | |||||
#include <__type_traits/remove_cvref.h> | |||||
#include <version> | #include <version> | ||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||||
# pragma GCC system_header | # pragma GCC system_header | ||||
#endif | #endif | ||||
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 | ||||
Show All 23 Lines | |||||
struct parallel_unsequenced_policy { | struct parallel_unsequenced_policy { | ||||
constexpr explicit parallel_unsequenced_policy(__disable_user_instantiations_tag) {} | constexpr explicit parallel_unsequenced_policy(__disable_user_instantiations_tag) {} | ||||
parallel_unsequenced_policy(const parallel_unsequenced_policy&) = delete; | parallel_unsequenced_policy(const parallel_unsequenced_policy&) = delete; | ||||
parallel_unsequenced_policy& operator=(const parallel_unsequenced_policy&) = delete; | parallel_unsequenced_policy& operator=(const parallel_unsequenced_policy&) = delete; | ||||
}; | }; | ||||
constexpr parallel_unsequenced_policy par_unseq{__disable_user_instantiations_tag{}}; | constexpr parallel_unsequenced_policy par_unseq{__disable_user_instantiations_tag{}}; | ||||
// TODO: Do we want to make this a supported extension in C++17? | |||||
ldionne: I would say no, as for most other extensions. | |||||
struct __unsequenced_policy { | |||||
constexpr explicit __unsequenced_policy(__disable_user_instantiations_tag) {} | |||||
__unsequenced_policy(const __unsequenced_policy&) = delete; | |||||
__unsequenced_policy& operator=(const __unsequenced_policy&) = delete; | |||||
}; | |||||
constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}}; | |||||
# if _LIBCPP_STD_VER >= 20 | # if _LIBCPP_STD_VER >= 20 | ||||
struct unsequenced_policy { | struct unsequenced_policy { | ||||
constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {} | constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {} | ||||
unsequenced_policy(const unsequenced_policy&) = delete; | unsequenced_policy(const unsequenced_policy&) = delete; | ||||
unsequenced_policy& operator=(const unsequenced_policy&) = delete; | unsequenced_policy& operator=(const unsequenced_policy&) = delete; | ||||
}; | }; | ||||
constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}}; | constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}}; | ||||
# endif // _LIBCPP_STD_VER >= 20 | # endif // _LIBCPP_STD_VER >= 20 | ||||
} // namespace execution | } // namespace execution | ||||
template <class> | |||||
inline constexpr bool is_execution_policy_v = false; | |||||
template <> | template <> | ||||
inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true; | inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true; | ||||
template <> | template <> | ||||
inline constexpr bool is_execution_policy_v<execution::parallel_policy> = true; | inline constexpr bool is_execution_policy_v<execution::parallel_policy> = true; | ||||
template <> | template <> | ||||
inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_policy> = true; | inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_policy> = true; | ||||
template <> | |||||
inline constexpr bool is_execution_policy_v<execution::__unsequenced_policy> = true; | |||||
template <> | |||||
inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_policy> = true; | |||||
template <> | |||||
inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_unsequenced_policy> = true; | |||||
template <> | |||||
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::__unsequenced_policy> = true; | |||||
template <> | |||||
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::parallel_unsequenced_policy> = true; | |||||
# if _LIBCPP_STD_VER >= 20 | # if _LIBCPP_STD_VER >= 20 | ||||
template <> | template <> | ||||
inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true; | inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true; | ||||
template <> | |||||
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::unsequenced_policy> = true; | |||||
# endif | # endif | ||||
template <class _Tp> | template <class _Tp> | ||||
struct is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {}; | struct is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {}; | ||||
template <class _ExecutionPolicy> | |||||
auto&& __remove_parallel_policy(_ExecutionPolicy&&) { | |||||
using _ExecPol = remove_cvref_t<_ExecutionPolicy>; | |||||
if constexpr(is_same_v<_ExecPol, execution::parallel_policy>) { | |||||
return execution::seq; | |||||
} else if constexpr (is_same_v<_ExecPol, execution::parallel_unsequenced_policy>) { | |||||
return execution::__unseq; | |||||
} | |||||
} | |||||
_LIBCPP_END_NAMESPACE_STD | _LIBCPP_END_NAMESPACE_STD | ||||
#endif // defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 | #endif // defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 | ||||
#endif // _LIBCPP_EXECUTION | #endif // _LIBCPP_EXECUTION |
I would say no, as for most other extensions.