21 #ifndef GRPPI_POLY_POLYMORPHIC_EXECUTION_H 22 #define GRPPI_POLY_POLYMORPHIC_EXECUTION_H 24 #include "../seq/sequential_execution.h" 25 #include "../native/parallel_execution_native.h" 26 #include "../tbb/parallel_execution_tbb.h" 27 #include "../omp/parallel_execution_omp.h" 37 return is_sequential_execution<E>()
38 || is_parallel_execution_native<E>()
39 || is_parallel_execution_tbb<E>()
40 || is_parallel_execution_omp<E>()
47 std::enable_if_t<is_execution_policy<E>(),
int>;
52 std::enable_if_t<!is_execution_policy<E>(),
int>;
69 execution_type_{
nullptr}
73 bool has_execution() const noexcept {
return execution_.get() !=
nullptr; }
77 const std::type_info &
type() const noexcept {
78 return *execution_type_;
85 return typeid(E) == *execution_type_;
93 if (*execution_type_ !=
typeid(E))
return nullptr;
94 return static_cast<E*
>(execution_.get());
106 std::shared_ptr<void> execution_;
109 const std::type_info * execution_type_;
116 template <
typename E>
119 if (!is_supported<E>())
return e;
120 e.execution_ = std::make_shared<E>();
121 e.execution_type_ = &
typeid(E);
Definition: callable_traits.h:24
friend polymorphic_execution make_polymorphic_execution()
Definition: polymorphic_execution.h:117
polymorphic_execution make_polymorphic_execution()
Definition: polymorphic_execution.h:117
bool is_execution() const
Definition: polymorphic_execution.h:83
const std::type_info & type() const noexcept
Definition: polymorphic_execution.h:77
std::enable_if_t< is_execution_policy< E >(), int > requires_execution_policy
Simulate concept requirement for being an execution policy.
Definition: polymorphic_execution.h:47
constexpr bool is_execution_policy()
Meta-function to determine if a type is an execution policy.
Definition: polymorphic_execution.h:36
bool has_execution() const noexcept
Determine if there is an execution stored.
Definition: polymorphic_execution.h:73
E * execution_ptr()
Get the execution pointer for a given type.
Definition: polymorphic_execution.h:91
Definition: polymorphic_execution.h:63
polymorphic_execution() noexcept
Create empty polymorphic execution.
Definition: polymorphic_execution.h:67
std::enable_if_t<!is_execution_policy< E >(), int > requires_not_execution_policy
Simulate concept requirement for not being an execution policy.
Definition: polymorphic_execution.h:52