This is an automated email from the ASF dual-hosted git repository.
jonkeane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 7c20b7b8c7b GH-50019: [CI][C++] Add fallbacks for
`std::ranges::[any_of|all_of]` on older pre-full-C++20 SDKs (#50020)
7c20b7b8c7b is described below
commit 7c20b7b8c7b1cb015f80a3bb36f8e45f2c3ea68e
Author: Jonathan Keane <[email protected]>
AuthorDate: Sat May 23 08:47:16 2026 -0500
GH-50019: [CI][C++] Add fallbacks for `std::ranges::[any_of|all_of]` on
older pre-full-C++20 SDKs (#50020)
### Rationale for this change
Fixes the macos-CRAN failure in our crossbow jobs.
### What changes are included in this PR?
Use the same workaround we have been to define the old(er) approach only
when we are on an SDK that doesn't have full C++20 support
### Are these changes tested?
Yes, crossbow
### Are there any user-facing changes?
No
* GitHub Issue: #50019
Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Jonathan Keane <[email protected]>
---
cpp/src/arrow/util/dispatch_internal.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/cpp/src/arrow/util/dispatch_internal.h
b/cpp/src/arrow/util/dispatch_internal.h
index 1552e846a48..36e5152ee65 100644
--- a/cpp/src/arrow/util/dispatch_internal.h
+++ b/cpp/src/arrow/util/dispatch_internal.h
@@ -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.