This is an automated email from the ASF dual-hosted git repository.
thisisnic 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 ca6ab6ffc89 GH-55429: [C++] std::invocable in codegen_internal.h fails
to compile with CRAN's macOS 11.3 SDK (#55457)
ca6ab6ffc89 is described below
commit ca6ab6ffc89cc91e3d8581b8cd9579c4fab22568
Author: Nic Crane <[email protected]>
AuthorDate: Mon Nov 9 16:07:07 2026 -0500
GH-55429: [C++] std::invocable in codegen_internal.h fails to compile with
CRAN's macOS 11.3 SDK (#55457)
### Rationale for this change
macOS on CRAN is old and doesn't have all the C++20 stuff in it - evidenced
by failing CI
### What changes are included in this PR?
Refactor code which requires newer stuff that the CRAN stuff doesn't have
### Are these changes tested?
Will run CI
### Are there any user-facing changes?
Nah
### Was AI used for this PR?
Yeah, all generated but I checked it with an adversarial review and will
run CI to make sure it actually works
**PR code and description written by:**
- [x] Human
- [x] AI
**Reviewed before submission by:**
- [x] Human
- [x] AI
- [ ] Not reviewed
* GitHub Issue: #55429
Lead-authored-by: Nic Crane <[email protected]>
Co-authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
---
cpp/src/arrow/compute/kernels/codegen_internal.h | 8 +++++---
cpp/src/parquet/column_reader.cc | 25 +++++++++++++++++++++---
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/cpp/src/arrow/compute/kernels/codegen_internal.h
b/cpp/src/arrow/compute/kernels/codegen_internal.h
index 405f35a9234..d51fd7c9a0e 100644
--- a/cpp/src/arrow/compute/kernels/codegen_internal.h
+++ b/cpp/src/arrow/compute/kernels/codegen_internal.h
@@ -17,7 +17,6 @@
#pragma once
-#include <concepts>
#include <cstdint>
#include <cstring>
#include <memory>
@@ -1234,9 +1233,12 @@ struct GeneratorApplicator<Generator, Arg1,
WithFirstTypeTwice, Args...> {
using Type = GeneratorApplicator<Generator, Arg1, Arg1, Args...>::Type;
};
+// std::is_invocable_v is used instead of the std::invocable concept because
some
+// older standard library implementations (e.g., macOS 11.x libc++, used by
CRAN)
+// have partial C++20 concepts support and lack std::invocable.
template <auto Transform, auto TypeIdArray, size_t ArrayIndex,
template <typename...> class Generator, typename... Args>
- requires std::invocable<decltype(Transform), Type::type>
+ requires std::is_invocable_v<decltype(Transform), Type::type>
auto GenerateKernelExecImpl(Type::type id) {
constexpr auto kNumTypeIds = std::tuple_size_v<decltype(TypeIdArray)>;
static_assert(ArrayIndex < kNumTypeIds);
@@ -1272,7 +1274,7 @@ auto GenerateKernelExecImpl(Type::type id) {
template <auto Transform, auto TypeIdArray, template <typename...> class
Generator,
typename... Args>
- requires std::invocable<decltype(Transform), Type::type>
+ requires std::is_invocable_v<decltype(Transform), Type::type>
auto GenerateKernelExec(detail::GetTypeId get_id) {
return detail::GenerateKernelExecImpl<Transform, TypeIdArray,
/*ArrayIndex=*/0,
Generator, Args...>(get_id.id);
diff --git a/cpp/src/parquet/column_reader.cc b/cpp/src/parquet/column_reader.cc
index 6aca8a23ce1..8594acb41d6 100644
--- a/cpp/src/parquet/column_reader.cc
+++ b/cpp/src/parquet/column_reader.cc
@@ -83,10 +83,29 @@ inline void CheckNumberDecoded(int64_t number_decoded,
int64_t expected) {
}
}
-/// True if a T can hold a U.
+/// True if an integer type T can hold every value of integer type U.
+///
+/// Written in terms of std::numeric_limits rather than std::in_range because
+/// the libc++ in the macOS 11.3 SDK used by CRAN does not provide the latter.
+template <typename T, typename U>
+struct CanHold {
+ static_assert(std::is_integral_v<T> && std::is_integral_v<U>,
+ "can_hold_v is only defined for integer types");
+ static constexpr bool value =
+ std::numeric_limits<T>::digits >= std::numeric_limits<U>::digits &&
+ (std::is_signed_v<T> || !std::is_signed_v<U>);
+};
+
template <typename T, typename U>
-inline constexpr bool can_hold_v =
std::in_range<T>(std::numeric_limits<U>::min()) &&
-
std::in_range<T>(std::numeric_limits<U>::max());
+inline constexpr bool can_hold_v = CanHold<T, U>::value;
+
+static_assert(can_hold_v<int64_t, int32_t>);
+static_assert(can_hold_v<int64_t, uint32_t>);
+static_assert(can_hold_v<int32_t, int32_t>);
+static_assert(!can_hold_v<int32_t, int64_t>);
+static_assert(!can_hold_v<int32_t, uint32_t>);
+static_assert(!can_hold_v<uint32_t, int32_t>);
+static_assert(!can_hold_v<uint64_t, int32_t>);
/// Clamp to a given type.
template <typename T, typename U>