diff --git a/cpp/src/arrow/adapters/orc/util.cc b/cpp/src/arrow/adapters/orc/util.cc index 91260302abd3..7ab5efafdc1c 100644 --- a/cpp/src/arrow/adapters/orc/util.cc +++ b/cpp/src/arrow/adapters/orc/util.cc @@ -295,7 +295,7 @@ Status AppendUnionBatchInternal(const liborc::Type* type, RETURN_NOT_OK(AppendBatch(child_type, child_batch, start, /*length=*/1, builder->child_builder(child_id).get())); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { // Append null value to other child builders for sparse union type. for (int8_t field_id = 0; field_id < union_type->num_fields(); field_id++) { if (field_id != child_id) { @@ -844,10 +844,10 @@ Status WriteUnionBatch(const Array& array, int64_t orc_offset, int64_t child_array_orc_offset = batch->offsets[running_orc_offset]; int64_t child_array_arrow_offset; - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { child_array_arrow_offset = union_array->value_offset(running_arrow_offset); } else { - static_assert(std::is_same_v); + static_assert(std::same_as); child_array_arrow_offset = running_arrow_offset; } child_batch->resize(child_array_orc_offset + 1); diff --git a/cpp/src/arrow/array/array_test.cc b/cpp/src/arrow/array/array_test.cc index 2cdf94bfab95..655ca9b08f1d 100644 --- a/cpp/src/arrow/array/array_test.cc +++ b/cpp/src/arrow/array/array_test.cc @@ -2494,10 +2494,10 @@ void CheckFloatApproxEqualsWithUlpDistance() { if constexpr (is_half_float_type::value) { a.push_back(Float16(1.00097656)); b.push_back(Float16(0.999511719f)); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { a.push_back(CType(0.9999999999999999)); b.push_back(CType(1.0000000000000002)); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { a.push_back(CType(1.0000001f)); b.push_back(CType(0.99999994f)); } diff --git a/cpp/src/arrow/array/builder_primitive.h b/cpp/src/arrow/array/builder_primitive.h index 6d79d6e96499..6b6fc577ffb3 100644 --- a/cpp/src/arrow/array/builder_primitive.h +++ b/cpp/src/arrow/array/builder_primitive.h @@ -473,9 +473,9 @@ class ARROW_EXPORT HalfFloatBuilder : public NumericBuilder { /// @tparam T arrow::util::Float16 or value_type (uint16_t) template T GetValue(int64_t index) const { - static_assert(std::is_same_v || - std::is_same_v); - if constexpr (std::is_same_v) { + static_assert(std::same_as || + std::same_as); + if constexpr (std::same_as) { return BaseClass::GetValue(index); } else { return Float16::FromBits(BaseClass::GetValue(index)); diff --git a/cpp/src/arrow/array/data_test.cc b/cpp/src/arrow/array/data_test.cc index 9e103207d0f1..1190c15172aa 100644 --- a/cpp/src/arrow/array/data_test.cc +++ b/cpp/src/arrow/array/data_test.cc @@ -53,7 +53,7 @@ TEST(ArrayData, GetSpanRespectsOffset) { /*offset=*/1); auto span = data->GetSpan(1, 3); - const bool is_const_pointer = std::is_same_v; + const bool is_const_pointer = std::same_as; ASSERT_TRUE(is_const_pointer); EXPECT_EQ(span.size(), 3); @@ -73,7 +73,7 @@ TEST(ArrayData, GetMutableSpanRespectsOffset) { ArrayData::Make(uint16(), /*length=*/3, buffers, /*null_count=*/0, /*offset=*/1); auto span = data->GetMutableSpan(1, 3); - const bool is_mut_pointer = std::is_same_v; + const bool is_mut_pointer = std::same_as; ASSERT_TRUE(is_mut_pointer); EXPECT_EQ(span.size(), 3); diff --git a/cpp/src/arrow/array/dict_internal.h b/cpp/src/arrow/array/dict_internal.h index 8ddc4b448a7e..a8654b98cd82 100644 --- a/cpp/src/arrow/array/dict_internal.h +++ b/cpp/src/arrow/array/dict_internal.h @@ -154,7 +154,7 @@ template struct DictionaryTraits> { using MemoTableType = typename HashTraits::MemoTableType; - static_assert(std::is_same_v>); + static_assert(std::same_as>); // Instead of defining a custom memo table for StringView we reuse BinaryType's, // then convert to views when we copy data out of the memo table. diff --git a/cpp/src/arrow/array/validate.cc b/cpp/src/arrow/array/validate.cc index 16bc9187af46..1c56c768066b 100644 --- a/cpp/src/arrow/array/validate.cc +++ b/cpp/src/arrow/array/validate.cc @@ -47,8 +47,8 @@ struct UTF8DataValidator { template Status Visit(const T&) { - if constexpr (std::is_same_v || std::is_same_v || - std::is_same_v) { + if constexpr (std::same_as || std::same_as || + std::same_as) { util::InitializeUTF8(); int64_t i = 0; diff --git a/cpp/src/arrow/c/dlpack.cc b/cpp/src/arrow/c/dlpack.cc index 1b58b5a503c0..63358042318e 100644 --- a/cpp/src/arrow/c/dlpack.cc +++ b/cpp/src/arrow/c/dlpack.cc @@ -121,7 +121,7 @@ DT* ExportBuffer(ExportBufferParams&& p) { ctx->tensor.dl_tensor.byte_offset = 0; // Strides must be non-null when ndim > 0 ctx->tensor.dl_tensor.strides = ctx->strides.data(); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { ctx->tensor.version = kVersion; ctx->tensor.flags = p.flags; } diff --git a/cpp/src/arrow/c/dlpack_test.cc b/cpp/src/arrow/c/dlpack_test.cc index 8cbff0692da3..ae7301b95150 100644 --- a/cpp/src/arrow/c/dlpack_test.cc +++ b/cpp/src/arrow/c/dlpack_test.cc @@ -111,7 +111,7 @@ void CheckDLTensor(const std::shared_ptr& arr, ASSERT_EQ(DLDeviceType::kDLCPU, device.device_type); ASSERT_EQ(0, device.device_id); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { ASSERT_EQ(DLPACK_MAJOR_VERSION, dlmtensor->version.major); ASSERT_EQ(DLPACK_MINOR_VERSION, dlmtensor->version.minor); if constexpr (Producer::copy) { @@ -234,7 +234,7 @@ void CheckDLTensor(const std::shared_ptr& t, ASSERT_EQ(DLDeviceType::kDLCPU, device.device_type); ASSERT_EQ(0, device.device_id); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { ASSERT_EQ(DLPACK_MAJOR_VERSION, dlmtensor->version.major); ASSERT_EQ(DLPACK_MINOR_VERSION, dlmtensor->version.minor); if constexpr (Producer::copy) { @@ -296,7 +296,7 @@ TYPED_TEST(TestExportTensor, TestTensorReadOnly) { Tensor::Make(float32(), read_only_buffer, shape)); ASSERT_FALSE(read_only_tensor->is_mutable()); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { ASSERT_RAISES_WITH_MESSAGE( NotImplemented, "NotImplemented: Legacy DLPack support is not implemented for immutable tensors." diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc index 06f1d14e73a3..ad33c632f227 100644 --- a/cpp/src/arrow/compare.cc +++ b/cpp/src/arrow/compare.cc @@ -1540,7 +1540,7 @@ bool ArrayStatisticsOptionalValueEquals(const std::optional& left, const EqualOptions& options) { if (!left.has_value() || !right.has_value()) { return left.has_value() == right.has_value(); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return DoubleEquals(left.value(), right.value(), options); } else if (left->index() != right->index()) { return false; @@ -1551,7 +1551,7 @@ bool ArrayStatisticsOptionalValueEquals(const std::optional& left, if constexpr (std::conjunction_v, std::is_same>) { return DoubleEquals(v1, v2, options); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return v1 == v2; } Unreachable("The types are different."); diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc b/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc index 3733f415a048..c062822f8d3e 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc @@ -274,7 +274,7 @@ struct MeanImplcount < options.min_count)) { out->value = std::make_shared(); } else { - static_assert(std::is_same_vsum), double>, + static_assert(std::same_assum), double>, "SumCType must be double for numeric inputs"); const double mean = this->sum / this->count; out->value = std::make_shared(mean); diff --git a/cpp/src/arrow/compute/kernels/base_arithmetic_internal.h b/cpp/src/arrow/compute/kernels/base_arithmetic_internal.h index 320c40373c5a..5c7c78ef7307 100644 --- a/cpp/src/arrow/compute/kernels/base_arithmetic_internal.h +++ b/cpp/src/arrow/compute/kernels/base_arithmetic_internal.h @@ -729,7 +729,7 @@ template <> struct Identity { template static constexpr Value value() { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return Float16::zero(); } else { return 0; @@ -744,7 +744,7 @@ template <> struct Identity { template static constexpr Value value() { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return Float16::one(); } else { return 1; @@ -762,7 +762,7 @@ struct Identity { // Note that `min()` returns the smallest positive value for // floating-point types, and `lowest()` doesn't satisfy the identity // property for -inf inputs, so use -infinity for those types. - if constexpr (std::is_floating_point_v || std::is_same_v) { + if constexpr (std::is_floating_point_v || std::same_as) { return -std::numeric_limits::infinity(); } else { return std::numeric_limits::lowest(); @@ -775,7 +775,7 @@ struct Identity { template static constexpr Value value() { // Mirror of Identity: use +infinity for floating-point types. - if constexpr (std::is_floating_point_v || std::is_same_v) { + if constexpr (std::is_floating_point_v || std::same_as) { return std::numeric_limits::infinity(); } else { return std::numeric_limits::max(); diff --git a/cpp/src/arrow/compute/kernels/codegen_internal.h b/cpp/src/arrow/compute/kernels/codegen_internal.h index 3a2bcefab0a1..96d524f5b0d3 100644 --- a/cpp/src/arrow/compute/kernels/codegen_internal.h +++ b/cpp/src/arrow/compute/kernels/codegen_internal.h @@ -276,7 +276,7 @@ template using enable_if_not_floating_value = enable_if_t::value, R>; template -using enable_if_half_float_value = enable_if_t, R>; +using enable_if_half_float_value = enable_if_t, R>; template using enable_if_decimal_value = @@ -492,8 +492,8 @@ void VisitArrayValuesInline(const ArraySpan& arr, VisitFunc&& valid_func, } template - requires std::is_same_v::T>, - Status> + requires std::same_as::T>, + Status> Status VisitArrayValuesInline(const ArraySpan& arr, VisitFunc&& valid_func, NullFunc&& null_func) { return VisitArraySpanInline( @@ -622,7 +622,7 @@ struct OutputAdapter> { template struct OutputAdapter> { - using T = std::conditional_t, Float16, + using T = std::conditional_t, Float16, typename TypeTraits::ScalarType::ValueType>; template diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate_internal.h b/cpp/src/arrow/compute/kernels/hash_aggregate_internal.h index 1ba21bd9b89e..d990bb6ce5c1 100644 --- a/cpp/src/arrow/compute/kernels/hash_aggregate_internal.h +++ b/cpp/src/arrow/compute/kernels/hash_aggregate_internal.h @@ -176,7 +176,7 @@ void VisitGroupedValues(const ExecSpan& batch, ConsumeValue&& valid_func, } template - requires std::is_same_v< + requires std::same_as< std::invoke_result_t::T>, Status> Status VisitGroupedValues(const ExecSpan& batch, ConsumeValue&& valid_func, ConsumeNull&& null_func) { diff --git a/cpp/src/arrow/compute/kernels/ree_util_internal.h b/cpp/src/arrow/compute/kernels/ree_util_internal.h index 3e2bf8af87e9..571548e48691 100644 --- a/cpp/src/arrow/compute/kernels/ree_util_internal.h +++ b/cpp/src/arrow/compute/kernels/ree_util_internal.h @@ -76,7 +76,7 @@ class ReadWriteValue) { + if constexpr (std::same_as) { *out = bit_util::GetBit(input_values_, read_offset); } else { *out = (reinterpret_cast(input_values_))[read_offset]; @@ -88,7 +88,7 @@ class ReadWriteValue) { + if constexpr (std::same_as) { return bit_util::GetBit(input_values_, i) == bit_util::GetBit(input_values_, j); } else { return (reinterpret_cast(input_values_))[i] == @@ -111,7 +111,7 @@ class ReadWriteValue) { + if constexpr (std::same_as) { bit_util::SetBitTo(output_values_, write_offset, value); } else { (reinterpret_cast(output_values_))[write_offset] = value; @@ -125,7 +125,7 @@ class ReadWriteValue) { + if constexpr (std::same_as) { bit_util::SetBitsTo(reinterpret_cast(output_values_), write_offset, run_length, value); } else { diff --git a/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc b/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc index 11ba956071b1..1d9f6b475a72 100644 --- a/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc +++ b/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc @@ -91,7 +91,7 @@ template class TestBaseArithmetic : public ::testing::Test { protected: using ArrowType = T; - using CType = std::conditional_t, Float16, + using CType = std::conditional_t, Float16, typename ArrowType::c_type>; static std::shared_ptr type_singleton() { @@ -104,14 +104,14 @@ class TestBaseArithmetic : public ::testing::Test { template std::shared_ptr MakeScalar(V value) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return std::make_shared(Float16(value).bits()); } else { return *arrow::MakeScalar(type_singleton(), value); } } - static constexpr bool is_half_float() { return std::is_same_v; } + static constexpr bool is_half_float() { return std::same_as; } }; // This has to be a macro, the test wouldn't be skipped from a helper function @@ -122,7 +122,7 @@ class TestBaseArithmetic : public ::testing::Test { template using enable_if_numeric_value = - std::enable_if_t || std::is_same_v, R>; + std::enable_if_t || std::same_as, R>; template class TestBaseUnaryArithmetic : public TestBaseArithmetic { diff --git a/cpp/src/arrow/compute/kernels/scalar_nested.cc b/cpp/src/arrow/compute/kernels/scalar_nested.cc index e9c65aff1ce1..854260b2687c 100644 --- a/cpp/src/arrow/compute/kernels/scalar_nested.cc +++ b/cpp/src/arrow/compute/kernels/scalar_nested.cc @@ -249,7 +249,7 @@ struct ListSlice { RETURN_NOT_OK(MakeBuilder(pool, output_type, &builder)); auto* list_builder = checked_cast(builder.get()); RETURN_NOT_OK(list_builder->Resize(batch[0].array.length)); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { RETURN_NOT_OK(BuildArrayFromFixedSizeListType(opts.start, opts.step, opts.stop, batch, list_builder)); } else { @@ -267,8 +267,8 @@ struct ListSlice { std::optional stop, const ExecSpan& batch, BuilderType* out_list_builder) { - static_assert(std::is_same_v); - constexpr bool kIsFixedSizeOutput = std::is_same_v; + static_assert(std::same_as); + constexpr bool kIsFixedSizeOutput = std::same_as; const auto& fsl_type = checked_cast(*batch[0].type()); const ArraySpan& list_array = batch[0].array; const ArraySpan& values_array = list_array.child_data[0]; @@ -315,7 +315,7 @@ struct ListSlice { const ExecSpan& batch, BuilderType* out_list_builder) { constexpr bool kIsListViewInput = is_list_view(InListType::type_id); - constexpr bool kIsFixedSizeOutput = std::is_same_v; + constexpr bool kIsFixedSizeOutput = std::same_as; const ArraySpan& list_array = batch[0].array; const ArraySpan& values_array = list_array.child_data[0]; ArrayBuilder* value_builder = out_list_builder->value_builder(); diff --git a/cpp/src/arrow/compute/kernels/scalar_round_arithmetic_test.cc b/cpp/src/arrow/compute/kernels/scalar_round_arithmetic_test.cc index 1e9e0c9d50cf..77b9719c3618 100644 --- a/cpp/src/arrow/compute/kernels/scalar_round_arithmetic_test.cc +++ b/cpp/src/arrow/compute/kernels/scalar_round_arithmetic_test.cc @@ -1165,7 +1165,7 @@ TYPED_TEST(TestUnaryRoundSigned, Round) { // Test different rounding mode // skip int8 because of its small range - if constexpr (!std::is_same_v) { + if constexpr (!std::same_as) { std::string values("[0, 1, -13, -50, 115, -150, -176, 200, 250]"); this->SetRoundNdigits(-2); std::vector> round_modes_and_expected{{ @@ -1193,14 +1193,14 @@ TYPED_TEST(TestUnaryRoundSigned, Round) { this->AssertUnaryOpRaises(Round, "[1]", "out of range"); // Overflow is also treated as error - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundNdigits(-1); this->SetRoundMode(RoundMode::DOWN); this->AssertUnaryOpRaises(Round, "[-127]", "overflow"); } // A larger than double int64 should be correctly handled - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundNdigits(-2); this->SetRoundMode(RoundMode::UP); auto values = "[1152921504606846976]"; // 2 ^ 60 @@ -1235,7 +1235,7 @@ TYPED_TEST(TestUnaryRoundUnsigned, Round) { // Test different rounding mode // skip uint8 because of its small range - if constexpr (!std::is_same_v) { + if constexpr (!std::same_as) { std::string values("[0, 1, 13, 50, 115, 150, 176, 200, 250]"); this->SetRoundNdigits(-2); std::vector> round_modes_and_expected{{ @@ -1263,14 +1263,14 @@ TYPED_TEST(TestUnaryRoundUnsigned, Round) { this->AssertUnaryOpRaises(Round, "[1]", "out of range"); // Overflow is also treated as error - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundNdigits(-1); this->SetRoundMode(RoundMode::UP); this->AssertUnaryOpRaises(Round, "[255]", "overflow"); } // A larger than double uint64 should be correctly handled - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundNdigits(-2); this->SetRoundMode(RoundMode::UP); auto values = "[1152921504606846976]"; // 2 ^ 60 @@ -1373,13 +1373,13 @@ TYPED_TEST(TestBinaryRoundSigned, Round) { } // An overly large ndigits would cause an error - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundMode(RoundMode::UP); this->AssertBinaryOpRaises(RoundBinary, "[1]", "[-100]", "out of range"); } // Overflow is also treated as error - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundMode(RoundMode::DOWN); this->AssertBinaryOpRaises(RoundBinary, "[-127]", "[-1]", "overflow"); } @@ -1432,13 +1432,13 @@ TYPED_TEST(TestBinaryRoundUnsigned, Round) { } // An overly large ndigits would cause an error - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundMode(RoundMode::UP); this->AssertBinaryOpRaises(RoundBinary, "[1]", "[-100]", "out of range"); } // Overflow is also treated as error - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { this->SetRoundMode(RoundMode::UP); this->AssertBinaryOpRaises(RoundBinary, "[255]", "[-1]", "overflow"); } @@ -1544,7 +1544,7 @@ TYPED_TEST(TestUnaryRoundToMultipleSigned, RoundToMultiple) { ArrayFromJSON(this->type_singleton(), pair.second)); } - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { // Test overflow handling this->SetRoundMultiple(10); auto input = "[-2147483645]"; @@ -1621,7 +1621,7 @@ TYPED_TEST(TestUnaryRoundToMultipleUnsigned, RoundToMultiple) { ArrayFromJSON(this->type_singleton(), pair.second)); } - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { // Test overflow handling this->SetRoundMultiple(10); auto input = "[4294967295]"; diff --git a/cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc b/cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc index 74a29081ae86..0981aba279b5 100644 --- a/cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc +++ b/cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc @@ -180,7 +180,7 @@ struct TemporalComponentExtractRound static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { const RoundTemporalOptions& options = RoundTemporalState::Get(ctx); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { if (options.calendar_based_origin) { return Status::Invalid( "calendar_based_origin is not supported for duration inputs"); diff --git a/cpp/src/arrow/compute/kernels/scalar_validity.cc b/cpp/src/arrow/compute/kernels/scalar_validity.cc index 5913b756f1c0..8e6037caf69c 100644 --- a/cpp/src/arrow/compute/kernels/scalar_validity.cc +++ b/cpp/src/arrow/compute/kernels/scalar_validity.cc @@ -63,7 +63,7 @@ Status IsValidExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { struct IsFiniteOperator { template static constexpr OutType Call(KernelContext*, const InType& value, Status*) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return value.is_finite(); } else { return std::isfinite(value); @@ -74,7 +74,7 @@ struct IsFiniteOperator { struct IsInfOperator { template static constexpr OutType Call(KernelContext*, const InType& value, Status*) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return value.is_infinity(); } else { return std::isinf(value); @@ -89,7 +89,7 @@ static void SetNanBits(const ArraySpan& arr, uint8_t* out_bitmap, int64_t out_of const T* data = arr.GetValues(1); for (int64_t i = 0; i < arr.length; ++i) { bool is_nan(false); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { is_nan = Float16::FromBits(data[i]).is_nan(); } else { is_nan = std::isnan(data[i]); @@ -143,7 +143,7 @@ Status IsNullExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { struct IsNanOperator { template static constexpr OutType Call(KernelContext*, const InType& value, Status*) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return value.is_nan(); } else { return std::isnan(value); diff --git a/cpp/src/arrow/field_ref_test.cc b/cpp/src/arrow/field_ref_test.cc index 25c8aa0b7162..dd776adaf13b 100644 --- a/cpp/src/arrow/field_ref_test.cc +++ b/cpp/src/arrow/field_ref_test.cc @@ -48,13 +48,13 @@ struct FieldPathTestCase { template const auto& OutputAs() const { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return field; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return array; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return array->data(); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return chunked_array; } } @@ -79,19 +79,19 @@ struct FieldPathTestCase { template const auto& InputAs() const { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return schema; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return type; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return array; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return array->data(); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return record_batch; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return chunked_array; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { return table; } } @@ -246,7 +246,7 @@ class FieldPathTestFixture : public ::testing::Test { // they're reused to create the input Table (which has a distinct chunking per // column). However, if the input was the ChunkedArray, the returned outputs should // always have the same num_chunks as the input. - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { EXPECT_EQ(case_->chunked_array->num_chunks(), actual->num_chunks()); } else { EXPECT_EQ(expected->num_chunks(), actual->num_chunks()); @@ -287,7 +287,7 @@ class TestFieldPath : public FieldPathTestFixture { using O = OutputType; auto result = DoGet(*case_->InputAs(), FieldPath({1, 1, 2})); std::string substr = "index out of range. indices=[ 1 1 >2< ] "; - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { substr += "fields: { a: float, a: bool, }"; } else { substr += "column types: { float, bool, }"; diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index 6f2780ddc05d..24e838fd5d50 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -84,7 +84,7 @@ inline bool IsConnectError(const Aws::Client::AWSError& error) { template inline std::optional BucketRegionFromError( const Aws::Client::AWSError& error) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { const auto& headers = error.GetResponseHeaders(); const auto it = headers.find("x-amz-bucket-region"); if (it != headers.end()) { diff --git a/cpp/src/arrow/flight/flight_internals_test.cc b/cpp/src/arrow/flight/flight_internals_test.cc index a66ac210b861..f3a394a037d3 100644 --- a/cpp/src/arrow/flight/flight_internals_test.cc +++ b/cpp/src/arrow/flight/flight_internals_test.cc @@ -69,8 +69,8 @@ void TestRoundtrip(const std::vector& values, ASSERT_OK_AND_ASSIGN(std::string serialized, values[i].SerializeToString()); ASSERT_OK_AND_ASSIGN(auto deserialized, FlightType::Deserialize(serialized)); - if constexpr (std::is_same_v || - std::is_same_v) { + if constexpr (std::same_as || + std::same_as) { ARROW_SCOPED_TRACE("Deserialized = ", deserialized->ToString()); EXPECT_EQ(values[i], *deserialized); } else { @@ -83,11 +83,11 @@ void TestRoundtrip(const std::vector& values, PbType pb_value; ASSERT_OK(internal::ToProto(values[i], &pb_value)); - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { FlightInfo::Data info_data; ASSERT_OK(internal::FromProto(pb_value, &info_data)); EXPECT_EQ(values[i], FlightInfo{std::move(info_data)}); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { SchemaResult value; ASSERT_OK(internal::FromProto(pb_value, &value)); EXPECT_EQ(values[i], value); diff --git a/cpp/src/arrow/flight/sql/odbc/tests/statement_test.cc b/cpp/src/arrow/flight/sql/odbc/tests/statement_test.cc index ba8b883aac47..7ed5ba631d27 100644 --- a/cpp/src/arrow/flight/sql/odbc/tests/statement_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/tests/statement_test.cc @@ -1058,9 +1058,9 @@ TYPED_TEST(StatementTest, DISABLED_TestSQLExecDirectFloatTruncation) { // Test is disabled until float truncation is supported. // GH-46985: return warning message instead of error on float truncation case std::wstring wsql; - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { wsql = L"SELECT CAST(1.234 AS REAL) AS float_val"; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { wsql = L"SELECT CAST(1.234 AS FLOAT) AS float_val"; } std::vector sql0(wsql.begin(), wsql.end()); diff --git a/cpp/src/arrow/record_batch_test.cc b/cpp/src/arrow/record_batch_test.cc index fea47244daf1..a59c88abf93a 100644 --- a/cpp/src/arrow/record_batch_test.cc +++ b/cpp/src/arrow/record_batch_test.cc @@ -1933,7 +1933,7 @@ class TestRecordBatchMakeStatisticsArrayBinary : public ::testing::Test { } std::shared_ptr<::arrow::DataType> type() { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return fixed_size_binary(1); } else { return TypeTraits::type_singleton(); diff --git a/cpp/src/arrow/result_test.cc b/cpp/src/arrow/result_test.cc index ad92841a6e70..3bcae805862e 100644 --- a/cpp/src/arrow/result_test.cc +++ b/cpp/src/arrow/result_test.cc @@ -642,18 +642,18 @@ TEST(ResultTest, MapFunctionToStatus) { const Result const_result(MoveOnlyDataType{kIntElement}); auto const_mapped = const_result.Map([](const MoveOnlyDataType& m) -> Status { return Status::OK(); }); - static_assert(std::is_same_v); + static_assert(std::same_as); EXPECT_TRUE(const_mapped.ok()); auto move_mapped = Result(MoveOnlyDataType{kIntElement}) .Map([](MoveOnlyDataType m) -> Status { return Status::OK(); }); - static_assert(std::is_same_v); + static_assert(std::same_as); EXPECT_TRUE(move_mapped.ok()); const Result error_result(error); auto error_mapped = error_result.Map([](const MoveOnlyDataType& m) -> Status { return Status::OK(); }); - static_assert(std::is_same_v); + static_assert(std::same_as); EXPECT_FALSE(error_mapped.ok()); EXPECT_EQ(error_mapped, error); } diff --git a/cpp/src/arrow/scalar.h b/cpp/src/arrow/scalar.h index 3e79d25d629c..153aebbc5b5c 100644 --- a/cpp/src/arrow/scalar.h +++ b/cpp/src/arrow/scalar.h @@ -1001,7 +1001,7 @@ struct MakeScalarImpl { // This isn't captured by the generic case above because `util::Float16` isn't implicity // convertible to `uint16_t` (HalfFloat's ValueType) template - std::enable_if_t, util::Float16> && + std::enable_if_t, util::Float16> && is_half_float_type::value, Status> Visit(const T& t) { diff --git a/cpp/src/arrow/tensor.cc b/cpp/src/arrow/tensor.cc index 8b3137d66a35..34a9811d5083 100644 --- a/cpp/src/arrow/tensor.cc +++ b/cpp/src/arrow/tensor.cc @@ -264,7 +264,7 @@ struct ConvertArrayToTensorVisitor { auto in_values = ArraySpan(in_data).GetSpan(1, in_data.length); if (in_data.null_count == 0) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { memcpy(out_values, in_values.data(), in_values.size_bytes()); out_values += in_values.size(); } else { @@ -274,7 +274,7 @@ struct ConvertArrayToTensorVisitor { } } else { for (int64_t i = 0; i < in_data.length; ++i) { - if constexpr (T::type_id == Type::HALF_FLOAT && std::is_same_v) { + if constexpr (T::type_id == Type::HALF_FLOAT && std::same_as) { *out_values++ = in_data.IsNull(i) ? std::numeric_limits::quiet_NaN().bits() : static_cast(in_values[i]); @@ -312,7 +312,7 @@ struct ConvertArrayToTensorRowMajorVisitor { } } else { for (int64_t i = 0; i < in_data.length; ++i) { - if constexpr (T::type_id == Type::HALF_FLOAT && std::is_same_v) { + if constexpr (T::type_id == Type::HALF_FLOAT && std::same_as) { out_values[base + i * num_cols] = in_data.IsNull(i) ? std::numeric_limits::quiet_NaN().bits() : static_cast(in_values[i]); @@ -338,7 +338,7 @@ inline void ConvertColumnsToTensor(const Container& container, uint8_t* out, const int num_columns = container.num_columns(); for (int col_idx = 0; col_idx < num_columns; ++col_idx) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { int64_t chunk_idx = 0; for (const auto& chunk : container.columns()[col_idx]->chunks()) { @@ -352,7 +352,7 @@ inline void ConvertColumnsToTensor(const Container& container, uint8_t* out, DCHECK_OK(VisitTypeInline(*chunk->type(), &visitor)); } } - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { const auto& array_data = container.column_data()[col_idx]; if (row_major) { @@ -379,9 +379,9 @@ Status ToTensorImpl(const Container& container, bool null_to_nan, bool row_major // if null_to_nan conversion is set to false for (int i = 0; i < container.num_columns(); ++i) { int64_t null_count = 0; - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { null_count = container.column(i)->null_count(); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::same_as) { null_count = container.column_data(i)->GetNullCount(); } if (null_count > 0 && !null_to_nan) { diff --git a/cpp/src/arrow/testing/math.cc b/cpp/src/arrow/testing/math.cc index df65544f0690..95da55b19a74 100644 --- a/cpp/src/arrow/testing/math.cc +++ b/cpp/src/arrow/testing/math.cc @@ -32,7 +32,7 @@ namespace { template bool WithinUlpGeneric(Float left, Float right, int32_t n_ulps) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { if (left.is_nan() || right.is_nan()) { return left.is_nan() == right.is_nan(); } diff --git a/cpp/src/arrow/testing/random.cc b/cpp/src/arrow/testing/random.cc index db7a60e4400f..28dfd3a28118 100644 --- a/cpp/src/arrow/testing/random.cc +++ b/cpp/src/arrow/testing/random.cc @@ -93,7 +93,7 @@ struct GeneratorFactory { template struct GenerateOptions { - static constexpr bool kIsHalfFloat = std::is_same_v; + static constexpr bool kIsHalfFloat = std::same_as; using PhysicalType = std::conditional_t; using FactoryType = GeneratorFactory; @@ -408,7 +408,7 @@ struct SmallDecimalGenerator { std::shared_ptr MakeRandomArray(int64_t size, double null_probability, int64_t alignment, MemoryPool* memory_pool) { static constexpr int32_t kMaxDigitsInInteger = - std::is_same_v ? 9 : 18; + std::same_as ? 9 : 18; static_assert( kMaxDigitsInInteger >= DecimalType::kByteWidth, "inconsistent decimal metadata: kMaxPrecision doesn't match kByteWidth"); diff --git a/cpp/src/arrow/type.cc b/cpp/src/arrow/type.cc index e841f0918097..c7471c8ce5c1 100644 --- a/cpp/src/arrow/type.cc +++ b/cpp/src/arrow/type.cc @@ -1621,7 +1621,7 @@ struct NestedSelectorUtil { template static const DataType* GetType(const T& input) { - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { return input.type.get(); } else { return input.type().get(); @@ -1658,7 +1658,7 @@ class NestedSelector { const DataType* type = Util::GetType(*parent); // We avoid this check for schema fields since it's inconsequential (plus there are // tests elsewhere that rely on it not happening) - if constexpr (!std::is_same_v) { + if constexpr (!std::same_as) { if (ARROW_PREDICT_FALSE(type->id() != Type::STRUCT)) { return Util::NonStructError(); } @@ -1681,7 +1681,7 @@ class NestedSelector { } template - std::enable_if_t> Summarize(OStream* os) const { + std::enable_if_t> Summarize(OStream* os) const { const FieldVector* fields = get_children(); if (!fields && get_parent()) { fields = &get_parent()->type()->fields(); @@ -1696,7 +1696,7 @@ class NestedSelector { } template - std::enable_if_t> Summarize(OStream* os) const { + std::enable_if_t> Summarize(OStream* os) const { *os << "column types: { "; if (auto children = get_children()) { for (const auto& child : *children) { diff --git a/cpp/src/arrow/type_test.cc b/cpp/src/arrow/type_test.cc index 133afbfa0c58..b25755983f87 100644 --- a/cpp/src/arrow/type_test.cc +++ b/cpp/src/arrow/type_test.cc @@ -1494,17 +1494,17 @@ PRIMITIVE_TEST(DoubleType, double, DOUBLE, "double"); PRIMITIVE_TEST(BooleanType, bool, BOOL, "bool"); TEST(TypesTest, DecimalTraits) { - static_assert(std::is_same_v::CType, Decimal32>); - static_assert(std::is_same_v::ArrowType, Decimal32Type>); + static_assert(std::same_as::CType, Decimal32>); + static_assert(std::same_as::ArrowType, Decimal32Type>); - static_assert(std::is_same_v::CType, Decimal64>); - static_assert(std::is_same_v::ArrowType, Decimal64Type>); + static_assert(std::same_as::CType, Decimal64>); + static_assert(std::same_as::ArrowType, Decimal64Type>); - static_assert(std::is_same_v::CType, Decimal128>); - static_assert(std::is_same_v::ArrowType, Decimal128Type>); + static_assert(std::same_as::CType, Decimal128>); + static_assert(std::same_as::ArrowType, Decimal128Type>); - static_assert(std::is_same_v::CType, Decimal256>); - static_assert(std::is_same_v::ArrowType, Decimal256Type>); + static_assert(std::same_as::CType, Decimal256>); + static_assert(std::same_as::ArrowType, Decimal256Type>); } TEST(TestBinaryType, ToString) { diff --git a/cpp/src/arrow/util/basic_decimal.h b/cpp/src/arrow/util/basic_decimal.h index 638c4870f1de..540ade4eabd9 100644 --- a/cpp/src/arrow/util/basic_decimal.h +++ b/cpp/src/arrow/util/basic_decimal.h @@ -171,7 +171,7 @@ template class ARROW_EXPORT SmallBasicDecimal { public: static_assert( - std::is_same_v || std::is_same_v, + std::same_as || std::same_as, "for bitwidths larger than 64 bits use BasicDecimal128 and BasicDecimal256"); static constexpr int kMaxPrecision = std::numeric_limits::digits10; diff --git a/cpp/src/arrow/util/bit_stream_utils_internal.h b/cpp/src/arrow/util/bit_stream_utils_internal.h index 10176e4257a8..7cd164c59539 100644 --- a/cpp/src/arrow/util/bit_stream_utils_internal.h +++ b/cpp/src/arrow/util/bit_stream_utils_internal.h @@ -281,7 +281,7 @@ inline int BitReader::GetBatch(int num_bits, T* v, int batch_size) { .max_read_bytes = max_bytes_ - byte_offset_, }; - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { ::arrow::internal::unpack(buffer_ + byte_offset_, v, opts); } else { @@ -307,7 +307,7 @@ inline bool BitReader::GetAligned(int num_bytes, T* v) { // Advance byte_offset to next unread byte and read num_bytes byte_offset_ += bytes_read; - if constexpr (std::is_same_v) { + if constexpr (std::same_as) { // ARROW-18031: if we're trying to get an aligned bool, just check // the LSB of the next byte and move on. If we memcpy + FromLittleEndian // as usual, we have potential undefined behavior for bools if the value diff --git a/cpp/src/arrow/util/bitmap_ops.cc b/cpp/src/arrow/util/bitmap_ops.cc index 5f76fa4e33d9..d751c1657126 100644 --- a/cpp/src/arrow/util/bitmap_ops.cc +++ b/cpp/src/arrow/util/bitmap_ops.cc @@ -237,7 +237,7 @@ void MapBitmapUnary(const uint8_t* data, int64_t offset, int64_t length, const uint8_t trail_mask = (1U << (8 - trailing_bits)) - 1; uint8_t last_data; - if constexpr (std::is_same_v, Identity>) { + if constexpr (std::same_as, Identity>) { std::memcpy(dest, data, static_cast(num_bytes - 1)); last_data = data[num_bytes - 1]; } else { diff --git a/cpp/src/arrow/util/bpacking_dispatch_internal.h b/cpp/src/arrow/util/bpacking_dispatch_internal.h index 6ea6adee1800..976bea4500f1 100644 --- a/cpp/src/arrow/util/bpacking_dispatch_internal.h +++ b/cpp/src/arrow/util/bpacking_dispatch_internal.h @@ -253,7 +253,7 @@ void unpack_width(const uint8_t* in, UnpackedUInt* out, int batch_size, int bit_ template