Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/algorithm/is execution policy"

From cppreference.com
< cpp‎ | algorithm
m (nospec)
m (Example: added a non-executable example (TBB back-end required).)
 
Line 2: Line 2:
 
{{cpp/algorithm/navbar}}
 
{{cpp/algorithm/navbar}}
  
{{ddcl | header = execution | since=c++17 | 1=
+
{{ddcl|header = execution|since=c++17|1=
 
template< class T >
 
template< class T >
 
struct is_execution_policy;
 
struct is_execution_policy;
Line 9: Line 9:
 
Checks whether {{tt|T}} is a standard or implementation-defined execution policy type.
 
Checks whether {{tt|T}} is a standard or implementation-defined execution policy type.
  
Provides the member constant {{tt|value}} which is equal to {{c|true}}, if {{tt|T}} is [[cpp/algorithm/execution_policy_tag_t|a standard execution policy type]], or an implementation-defined execution policy type. Otherwise, {{tt|value}} is equal to {{c|false}}.
+
Provides the member constant {{c|value}} which is equal to {{c|true}}, if {{tt|T}} is [[cpp/algorithm/execution_policy_tag_t|a standard execution policy type]], or an implementation-defined execution policy type. Otherwise, {{c|value}} is equal to {{c|false}}.
  
 
{{cpp/types/nospec|pv}}
 
{{cpp/types/nospec|pv}}
Line 15: Line 15:
 
===Template parameters===
 
===Template parameters===
 
{{par begin}}
 
{{par begin}}
{{par | T | a type to check}}
+
{{par|T|a type to check}}
 
{{par end}}
 
{{par end}}
  
=== Helper template ===
+
===Helper template===
{{ddcl | header = execution | since=c++17 | 1=
+
{{ddcl|header = execution|since=c++17|1=
 
template< class T >
 
template< class T >
inline constexpr bool is_execution_policy_v = std::is_execution_policy<T>::value;
+
constexpr bool is_execution_policy_v = std::is_execution_policy<T>::value;
 
}}
 
}}
  
{{cpp/types/integral_constant/inherit | {{tt|T}} is a standard or implementation-defined execution policy type}}
+
{{cpp/types/integral_constant/inherit|{{tt|T}} is a standard or implementation-defined execution policy type}}
 +
 
 +
{{example
 +
|code=
 +
#include <execution>
 +
 
 +
static_assert(std::is_execution_policy_v<std::execution::unsequenced_policy>);
 +
static_assert(!std::is_execution_policy_v<int>);
 +
 
 +
int main() {}
 +
}}
  
 
===See also===
 
===See also===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc inc | cpp/algorithm/dsc execution_policy_tag_t }}
+
{{dsc inc|cpp/algorithm/dsc execution_policy_tag_t}}
{{dsc inc | cpp/algorithm/dsc execution_policy_tag }}
+
{{dsc inc|cpp/algorithm/dsc execution_policy_tag}}
 
{{dsc end}}
 
{{dsc end}}
  
 
{{langlinks|es|ja|zh}}
 
{{langlinks|es|ja|zh}}

Latest revision as of 08:26, 24 September 2024

 
 
Algorithm library
Constrained algorithms and algorithms on ranges (C++20)
Constrained algorithms, e.g. ranges::copy, ranges::sort, ...
Execution policies (C++17)
is_execution_policy
(C++17)  
Non-modifying sequence operations
Batch operations
(C++17)
Search operations
(C++11)                (C++11)(C++11)

Modifying sequence operations
Copy operations
(C++11)
(C++11)
Swap operations
Transformation operations
Generation operations
Removing operations
Order-changing operations
(until C++17)(C++11)
(C++20)(C++20)
Sampling operations
(C++17)

Sorting and related operations
Partitioning operations
Sorting operations
Binary search operations
(on partitioned ranges)
Set operations (on sorted ranges)
Merge operations (on sorted ranges)
Heap operations
Minimum/maximum operations
(C++11)
(C++17)
Lexicographical comparison operations
Permutation operations
C library
Numeric operations
Operations on uninitialized memory
 
Defined in header <execution>
template< class T >
struct is_execution_policy;
(since C++17)

Checks whether T is a standard or implementation-defined execution policy type.

Provides the member constant value which is equal to true, if T is a standard execution policy type, or an implementation-defined execution policy type. Otherwise, value is equal to false.

If the program adds specializations for std::is_execution_policy or std::is_execution_policy_v, the behavior is undefined.

Contents

[edit] Template parameters

T - a type to check

[edit] Helper template

Defined in header <execution>
template< class T >
constexpr bool is_execution_policy_v = std::is_execution_policy<T>::value;
(since C++17)

Inherited from std::integral_constant

Member constants

value
[static]
true if T is a standard or implementation-defined execution policy type, false otherwise
(public static member constant)

Member functions

operator bool
converts the object to bool, returns value
(public member function)
operator()
(C++14)
returns value
(public member function)

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>
#include <execution>
 
static_assert(std::is_execution_policy_v<std::execution::unsequenced_policy>);
static_assert(!std::is_execution_policy_v<int>);
 
int main() {}

[edit] See also

execution policy types
(class) [edit]
(C++17)(C++17)(C++17)(C++20)
global execution policy objects
(constant) [edit]