-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
If a developer calls RAJA::forall with incorrect arguments, the compiler can sometimes emit confusing errors. This could be improved with cpp 20 concepts. For example, here is a concept in the context of RangeSegments
// GOAL: SIMPLIFY COMPILER ERRORS FROM forall
// Define concepts
template<typename ExecPolicy>
concept ExecutionPolicy = requires {
typename ExecPolicy::policy_tag; // or a RAJA-specific trait check
};
template<typename T>
concept Iterable = requires(T t) {
std::begin(t);
std::end(t);
};
template<typename F, typename Index>
concept CallableWithIndex = requires(F f, Index i) {
{ f(i) };
};
// Constrained forall version
template<
ExecutionPolicy ExecPolicy,
Iterable Range,
typename Body
> requires CallableWithIndex<Body, decltype(*std::begin(std::declval<Range>()))>
void forall(ExecPolicy, Range&& range, Body&& body) {
for (auto i : range) {
body(i);
}
}
Metadata
Metadata
Assignees
Labels
No labels