diff --git a/cpp/src/arrow/util/bit_util_benchmark.cc b/cpp/src/arrow/util/bit_util_benchmark.cc index da624bec1986..bc4cdad99c5f 100644 --- a/cpp/src/arrow/util/bit_util_benchmark.cc +++ b/cpp/src/arrow/util/bit_util_benchmark.cc @@ -172,7 +172,7 @@ static void BenchmarkBitmapVisitBitsetAnd(benchmark::State& state) { static void BenchmarkBitmapVisitUInt8And(benchmark::State& state) { BenchmarkAndImpl(state, [](const internal::Bitmap(&bitmaps)[2], internal::Bitmap* out) { int64_t i = 0; - internal::Bitmap::VisitWords(bitmaps, [&](std::array uint8s) { + internal::Bitmap::VisitWords(bitmaps, [&](std::array uint8s) { reinterpret_cast(out->mutable_data())[i++] = uint8s[0] & uint8s[1]; }); }); diff --git a/cpp/src/arrow/util/bitmap.h b/cpp/src/arrow/util/bitmap.h index 49f319081fa4..4cba55a8adc5 100644 --- a/cpp/src/arrow/util/bitmap.h +++ b/cpp/src/arrow/util/bitmap.h @@ -21,12 +21,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include "arrow/buffer.h" @@ -36,7 +38,6 @@ #include "arrow/util/bitmap_writer.h" #include "arrow/util/compare.h" #include "arrow/util/endian.h" -#include "arrow/util/functional.h" #include "arrow/util/string_util.h" #include "arrow/util/visibility.h" @@ -145,9 +146,8 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, // carefully in other cases. // For 2 bitmaps or less, and/or smaller bitmaps, see also VisitTwoBitBlocksVoid // and BitmapUInt64Reader. - template >::type::value_type> + template + requires std::same_as&>> static int64_t VisitWords(const Bitmap (&bitmaps_arg)[N], Visitor&& visitor) { constexpr int64_t kBitWidth = sizeof(Word) * 8; @@ -248,13 +248,12 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, return min_offset; } - template >::type::value_type> + template static void RunVisitWordsAndWriteLoop(int64_t bit_length, std::array& readers, std::array& writers, Visitor&& visitor) { + using Word = decltype(readers[0].NextWord()); constexpr int64_t kBitWidth = sizeof(Word) * 8; std::array visited_words; @@ -318,6 +317,7 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, /// may be offset within the first visited word, but words will otherwise contain /// densely packed bits loaded from the bitmap. That offset within the first word is /// returned. + /// /// Visitor is expected to have the following signature /// [](const std::array& in_words, std::array* out_words){...} /// @@ -326,9 +326,9 @@ class ARROW_EXPORT Bitmap : public util::ToStringOstreamable, // carefully in other cases. // For 2 bitmaps or less, and/or smaller bitmaps, see also VisitTwoBitBlocksVoid // and BitmapUInt64Reader. - template >::type::value_type> + template + requires std::same_as< + void, std::invoke_result_t&, std::array*>> static void VisitWordsAndWrite(const std::array& bitmaps_arg, std::array* out_bitmaps_arg, Visitor&& visitor) { diff --git a/cpp/src/arrow/util/cache_benchmark.cc b/cpp/src/arrow/util/cache_benchmark.cc index 7439ee2f5013..071367d8ec60 100644 --- a/cpp/src/arrow/util/cache_benchmark.cc +++ b/cpp/src/arrow/util/cache_benchmark.cc @@ -126,7 +126,7 @@ static void BenchmarkMemoize(benchmark::State& state, Memoized&& mem, static void MemoizeLruCached(benchmark::State& state) { const auto keys = MakeStrings(kCacheSize, state.range(0)); const auto values = MakeStrings(kCacheSize, state.range(1)); - auto mem = MemoizeLru(Callable(values), kCacheSize); + auto mem = MemoizeLru(Callable(values), kCacheSize); BenchmarkMemoize(state, mem, keys); } @@ -135,7 +135,8 @@ static void MemoizeLruCachedThreadUnsafe(benchmark::State& state) { const auto values = MakeStrings(kCacheSize, state.range(1)); // Emulate recommended usage of MemoizeLruCachedThreadUnsafe // (the compiler is probably able to cache the TLS-looked up value, though) - thread_local auto mem = MemoizeLruThreadUnsafe(Callable(values), kCacheSize); + thread_local auto mem = + MemoizeLruThreadUnsafe(Callable(values), kCacheSize); BenchmarkMemoize(state, mem, keys); } diff --git a/cpp/src/arrow/util/cache_internal.h b/cpp/src/arrow/util/cache_internal.h index fe10af8bb2aa..6c65712060f0 100644 --- a/cpp/src/arrow/util/cache_internal.h +++ b/cpp/src/arrow/util/cache_internal.h @@ -26,7 +26,6 @@ #include #include -#include "arrow/util/functional.h" #include "arrow/util/logging.h" #include "arrow/util/macros.h" @@ -167,11 +166,12 @@ struct ThreadUnsafeMemoizer { }; template