From 04d5a78eefe5161a4f36e266a4b49e1a7294ff1b Mon Sep 17 00:00:00 2001 From: Zehua Zou <41586196+HuaHuaY@users.noreply.github.com> Date: Wed, 7 Jan 2026 19:34:20 +0800 Subject: [PATCH] refactor: use remove_cvref_t instead of decay_t to get exact type --- src/iceberg/expression/literal.cc | 2 +- src/iceberg/manifest/manifest_reader.cc | 6 +++--- src/iceberg/snapshot.cc | 2 +- src/iceberg/test/matchers.h | 10 +++++----- src/iceberg/test/visit_type_test.cc | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/iceberg/expression/literal.cc b/src/iceberg/expression/literal.cc index cb0a4c6d0..88bafd78d 100644 --- a/src/iceberg/expression/literal.cc +++ b/src/iceberg/expression/literal.cc @@ -583,7 +583,7 @@ Result LiteralCaster::CastTo(const Literal& literal, std::size_t LiteralValueHash::operator()(const Literal::Value& value) const noexcept { return std::visit( [](const auto& v) -> std::size_t { - using T = std::decay_t; + using T = std::remove_cvref_t; constexpr size_t kHashPrime = 0x9e3779b9; diff --git a/src/iceberg/manifest/manifest_reader.cc b/src/iceberg/manifest/manifest_reader.cc index da109c3f1..693b9fc55 100644 --- a/src/iceberg/manifest/manifest_reader.cc +++ b/src/iceberg/manifest/manifest_reader.cc @@ -119,7 +119,7 @@ template requires std::ranges::forward_range Status ParseIntegerField(const ArrowArrayView* array_view, Container& container, Accessor accessor, Args&&... args) { - using T = unwrap_optional_t>>>; return ParseField( [](const ArrowArrayView* view, int64_t row_idx) { @@ -165,11 +165,11 @@ void ParseVectorField(Transfer transfer, const ArrowArrayView* view, int64_t len template requires std::ranges::forward_range && - std::ranges::range>>> void ParseIntegerVectorField(const ArrowArrayView* view, int64_t length, Container& container, Accessor accessor) { - using T = unwrap_optional_t>>>>; return ParseVectorField( [](const ArrowArrayView* v, int64_t offset) { diff --git a/src/iceberg/snapshot.cc b/src/iceberg/snapshot.cc index 5b6aabc10..ba85e0491 100644 --- a/src/iceberg/snapshot.cc +++ b/src/iceberg/snapshot.cc @@ -39,7 +39,7 @@ bool SnapshotRef::Tag::Equals(const SnapshotRef::Tag& other) const { SnapshotRefType SnapshotRef::type() const noexcept { return std::visit( [&](const auto& retention) -> SnapshotRefType { - using T = std::decay_t; + using T = std::remove_cvref_t; if constexpr (std::is_same_v) { return SnapshotRefType::kBranch; } else { diff --git a/src/iceberg/test/matchers.h b/src/iceberg/test/matchers.h index 55d29be60..f8c703082 100644 --- a/src/iceberg/test/matchers.h +++ b/src/iceberg/test/matchers.h @@ -140,7 +140,7 @@ class HasValueMatcher { template auto HasValue(MatcherT&& matcher) { return ::testing::MakePolymorphicMatcher( - HasValueMatcher>(std::forward(matcher))); + HasValueMatcher>(std::forward(matcher))); } // Overload for the common case where we just want to check for presence of any value @@ -200,15 +200,15 @@ class ResultMatcher { // Factory function for ResultMatcher for values template auto ResultIs(MatcherT&& matcher) { - return ::testing::MakePolymorphicMatcher( - ResultMatcher>(true, std::forward(matcher))); + return ::testing::MakePolymorphicMatcher(ResultMatcher>( + true, std::forward(matcher))); } // Factory function for ResultMatcher for errors template auto ErrorIs(MatcherT&& matcher) { - return ::testing::MakePolymorphicMatcher( - ResultMatcher>(false, std::forward(matcher))); + return ::testing::MakePolymorphicMatcher(ResultMatcher>( + false, std::forward(matcher))); } // Evaluate `rexpr` which should return a Result. diff --git a/src/iceberg/test/visit_type_test.cc b/src/iceberg/test/visit_type_test.cc index 8adc85b4a..2e9247c53 100644 --- a/src/iceberg/test/visit_type_test.cc +++ b/src/iceberg/test/visit_type_test.cc @@ -228,7 +228,7 @@ TEST_P(TypeTest, VisitTypePrintToString) { TEST_P(TypeTest, VisitTypeReturnNestedTypeId) { auto visitor = [&](auto&& type) -> Result { - using Type = std::decay_t; + using Type = std::remove_cvref_t; // Check if the type is a nested type if constexpr (std::is_base_of_v) { return type.type_id();