bkietz commented on a change in pull request #8642: URL: https://github.com/apache/arrow/pull/8642#discussion_r521583351
########## File path: cpp/src/arrow/compute/kernels/scalar_cast_string.cc ########## @@ -92,12 +93,74 @@ struct Utf8Validator { }; template <typename I, typename O> -struct BinaryToStringSameWidthCastFunctor { +constexpr bool has_smaller_width() { + return sizeof(typename I::offset_type) < sizeof(typename O::offset_type); +} + +template <typename I, typename O> +constexpr bool has_same_width() { + return sizeof(typename I::offset_type) == sizeof(typename O::offset_type); +} + +// Cast same-width offsets (no-op) +template <typename I, typename O> +void CastBinaryToBinaryOffsets(enable_if_t<has_same_width<I, O>(), KernelContext*> ctx, + const ArrayData& input, ArrayData* output) {} + +// Upcast offsets +template <typename I, typename O> +void CastBinaryToBinaryOffsets(enable_if_t<has_smaller_width<I, O>(), KernelContext*> ctx, + const ArrayData& input, ArrayData* output) { Review comment: If constexpr can be emulated using `std::conditional<has_smaller_width<I, O>(), NarrowerImpl, WiderImpl>::template Exec<I, O>(ctx, input, output)` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org