Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cpp/src/arrow/util/dispatch_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,36 @@ constexpr bool DispatchIsStatic(DispatchLevel level) {
}

/// Return whether all function in the array can be statically dispatched.
// TODO: remove the #else branch when we no longer have partial C++20 support with CRAN.
template <typename Func>
constexpr bool DispatchFullyStatic(const DynamicDispatchTargets<Func> auto& targets) {
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
return std::ranges::all_of(targets, [](const DynamicDispatchTarget<Func>& trgt) {
return DispatchIsStatic(trgt.level);
});
#else
return std::all_of(targets.begin(), targets.end(),
[](const DynamicDispatchTarget<Func>& trgt) {
return DispatchIsStatic(trgt.level);
});
#endif
}

/// Return whether any function in the array can be statically dispatched.
/// Return false on empty sets.
// TODO: remove the #else branch when we no longer have partial C++20 support with CRAN.
template <typename Func>
constexpr bool DispatchHasStatic(const DynamicDispatchTargets<Func> auto& targets) {
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
return std::ranges::any_of(targets, [](const DynamicDispatchTarget<Func>& trgt) {
return DispatchIsStatic(trgt.level);
});
#else
return std::any_of(targets.begin(), targets.end(),
[](const DynamicDispatchTarget<Func>& trgt) {
return DispatchIsStatic(trgt.level);
});
#endif
}

/// Find the best dispatch target given a filter.
Expand Down
Loading