From 1826c0bed3ff413ef0d8ef90338acef068a9eaa0 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Thu, 27 Aug 2026 19:20:09 -0400 Subject: [PATCH] chore: migrate from deprecated absl types to std equivalents --- MODULE.bazel | 2 +- generator/internal/http_annotation_parser.cc | 5 ++-- .../internal/http_annotation_parser_test.cc | 15 ++++++----- generator/internal/http_option_utils.cc | 11 ++++---- generator/internal/longrunning.cc | 24 ++++++++--------- .../minimal/internal/common_v2_resources.cc | 7 ++--- google/cloud/bigtable/column_family.h | 6 ++--- google/cloud/bigtable/filters.h | 6 ++--- .../bigtable/internal/default_row_reader.cc | 7 ++--- google/cloud/bigtable/mutations.h | 5 ++-- google/cloud/bigtable/table.h | 14 +++++----- google/cloud/bigtable/value_test.cc | 2 +- google/cloud/future_generic.h | 3 +-- google/cloud/internal/future_impl.h | 5 ++-- google/cloud/internal/future_then_impl.h | 5 ++-- google/cloud/internal/type_list.h | 3 +-- google/cloud/rest_options.h | 1 + .../cloud/spanner/internal/connection_impl.cc | 5 ++-- google/cloud/storage/async/client.cc | 9 ++++--- google/cloud/storage/async/reader.cc | 7 ++--- google/cloud/storage/client.h | 3 +-- google/cloud/storage/client_object_test.cc | 3 ++- .../storage/examples/storage_async_samples.cc | 5 ++-- .../examples/storage_object_samples.cc | 17 ++++++------ .../connection_impl_appendable_upload_test.cc | 9 ++++--- .../async/connection_impl_read_test.cc | 5 ++-- .../async/connection_impl_upload_hash_test.cc | 13 ++++----- .../async/connection_impl_upload_test.cc | 11 ++++---- .../async/object_descriptor_reader_tracing.cc | 7 ++--- .../async/reader_connection_resume.cc | 7 ++--- .../async/reader_connection_tracing.cc | 7 ++--- .../async/writer_connection_buffered.cc | 27 ++++++++++--------- .../internal/async/writer_connection_impl.cc | 9 ++++--- .../async/writer_connection_resumed.cc | 21 ++++++++------- .../cloud/storage/internal/grpc/make_cord.h | 3 +-- .../internal/grpc/metrics_exporter_options.cc | 3 ++- google/cloud/storage/internal/tuple_filter.h | 5 ++-- .../list_objects_and_prefixes_reader.h | 5 ++-- .../tests/async_client_integration_test.cc | 5 ++-- .../storage/tests/object_integration_test.cc | 25 ++++++++--------- google/cloud/stream_range.h | 3 ++- .../cloud/testing_util/validate_metadata.cc | 3 +-- 42 files changed, 180 insertions(+), 158 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 6f08aaec5e0e3..2348ef5558578 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -23,7 +23,7 @@ module( bazel_dep(name = "platforms", version = "1.1.0") bazel_dep(name = "bazel_skylib", version = "1.9.2") bazel_dep(name = "rules_cc", version = "0.2.17") -bazel_dep(name = "abseil-cpp", version = "20250814.2") +bazel_dep(name = "abseil-cpp", version = "20260526.0") # For backwards compatibility with WORKSPACE. # The name "com_google_protobuf" is internally used by @bazel_tools, diff --git a/generator/internal/http_annotation_parser.cc b/generator/internal/http_annotation_parser.cc index 03096241d581a..2a188dfece8e0 100644 --- a/generator/internal/http_annotation_parser.cc +++ b/generator/internal/http_annotation_parser.cc @@ -19,6 +19,7 @@ #include "absl/strings/str_cat.h" #include #include +#include namespace google { namespace cloud { @@ -246,7 +247,7 @@ StatusOr ParsePathTemplate(absl::string_view input) { return MakeParseError(input, v->end, " end of input", GCP_ERROR_INFO()); } return PathTemplate{std::move(s->value), - absl::get(v->value.value)}; + std::get(v->value.value)}; } std::ostream& operator<<(std::ostream& os, PathTemplate::Segment const& rhs) { @@ -263,7 +264,7 @@ std::ostream& operator<<(std::ostream& os, PathTemplate::Segment const& rhs) { } }; os << "{"; - absl::visit(Visitor{os}, rhs.value); + std::visit(Visitor{os}, rhs.value); os << "}"; return os; } diff --git a/generator/internal/http_annotation_parser_test.cc b/generator/internal/http_annotation_parser_test.cc index ca6ea916b2978..f3ff0d980ba7f 100644 --- a/generator/internal/http_annotation_parser_test.cc +++ b/generator/internal/http_annotation_parser_test.cc @@ -17,6 +17,7 @@ #include #include #include +#include namespace google { namespace cloud { @@ -65,21 +66,21 @@ bool SameValues(PathTemplate::Segment const& a, struct Visitor { PathTemplate::Segment const& a; bool operator()(PathTemplate::Match const&) { - return absl::holds_alternative(a.value); + return std::holds_alternative(a.value); } bool operator()(PathTemplate::MatchRecursive const&) { - return absl::holds_alternative(a.value); + return std::holds_alternative(a.value); } bool operator()(std::string const& s) { - return absl::holds_alternative(a.value) && - absl::get(a.value) == s; + return std::holds_alternative(a.value) && + std::get(a.value) == s; } bool operator()(PathTemplate::Variable const& v) { - return absl::holds_alternative(a.value) && - SameValues(absl::get(a.value), v); + return std::holds_alternative(a.value) && + SameValues(std::get(a.value), v); } }; - return absl::visit(Visitor{a}, b.value); + return std::visit(Visitor{a}, b.value); } bool SameValues(PathTemplate const& a, PathTemplate const& b) { diff --git a/generator/internal/http_option_utils.cc b/generator/internal/http_option_utils.cc index c317cf3481f0a..05fb33fd172dd 100644 --- a/generator/internal/http_option_utils.cc +++ b/generator/internal/http_option_utils.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include using ::google::protobuf::MethodDescriptor; @@ -96,7 +97,7 @@ struct RestPathVisitor { void RestPathVisitorHelper( std::optional api_version, PathTemplate::Segment const& s, std::vector& path) { - absl::visit(RestPathVisitor{std::move(api_version), path}, s.value); + std::visit(RestPathVisitor{std::move(api_version), path}, s.value); } std::string FormatQueryParameterCode( @@ -319,15 +320,15 @@ HttpExtensionInfo ParseHttpExtension(google::api::HttpRule const& http_rule) { }; auto segment_formatter = [](std::string* out, std::shared_ptr const& s) { - out->append(absl::visit(SegmentAsStringVisitor{}, s->value)); + out->append(std::visit(SegmentAsStringVisitor{}, s->value)); }; auto api_version = FormatApiVersionFromUrlPattern(info.url_path); auto rest_path_visitor = RestPathVisitor(std::move(api_version), info.rest_path); for (auto const& s : parsed_http_rule->segments) { - if (absl::holds_alternative(s->value)) { - auto v = absl::get(s->value); + if (std::holds_alternative(s->value)) { + auto v = std::get(s->value); if (v.segments.empty()) { info.field_substitutions.emplace_back(v.field_path, v.field_path); } else { @@ -336,7 +337,7 @@ HttpExtensionInfo ParseHttpExtension(google::api::HttpRule const& http_rule) { } } - absl::visit(rest_path_visitor, s->value); + std::visit(rest_path_visitor, s->value); } info.rest_path_verb = parsed_http_rule->verb; diff --git a/generator/internal/longrunning.cc b/generator/internal/longrunning.cc index 51b17fd945b25..43985e751fc9f 100644 --- a/generator/internal/longrunning.cc +++ b/generator/internal/longrunning.cc @@ -19,9 +19,9 @@ #include "google/cloud/extended_operations.pb.h" #include "google/cloud/log.h" #include "absl/strings/str_cat.h" -#include "absl/types/variant.h" #include "google/longrunning/operations.pb.h" #include +#include using ::google::protobuf::Descriptor; using ::google::protobuf::MethodDescriptor; @@ -31,7 +31,7 @@ namespace cloud { namespace generator_internal { namespace { -absl::variant FullyQualifyMessageType( +std::variant FullyQualifyMessageType( MethodDescriptor const& method, std::string message_type) { Descriptor const* output_type = method.file()->pool()->FindMessageTypeByName(message_type); @@ -63,7 +63,7 @@ struct FormatDoxygenLinkVisitor { } }; -absl::variant +std::variant DeduceLongrunningOperationResponseType( MethodDescriptor const& method, google::longrunning::OperationInfo const& operation_info) { @@ -100,36 +100,36 @@ void SetLongrunningOperationMethodVars( if (IsGRPCLongrunningOperation(method)) { auto operation_info = method.options().GetExtension(google::longrunning::operation_info); - method_vars["longrunning_metadata_type"] = ProtoNameToCppName(absl::visit( + method_vars["longrunning_metadata_type"] = ProtoNameToCppName(std::visit( FullyQualifiedMessageTypeVisitor(), FullyQualifyMessageType(method, operation_info.metadata_type()))); - method_vars["longrunning_response_type"] = ProtoNameToCppName(absl::visit( + method_vars["longrunning_response_type"] = ProtoNameToCppName(std::visit( FullyQualifiedMessageTypeVisitor(), FullyQualifyMessageType(method, operation_info.response_type()))); auto deduced_response_type = DeduceLongrunningOperationResponseType(method, operation_info); method_vars["longrunning_deduced_response_message_type"] = - absl::visit(FullyQualifiedMessageTypeVisitor(), deduced_response_type); + std::visit(FullyQualifiedMessageTypeVisitor(), deduced_response_type); method_vars["longrunning_deduced_response_type"] = ProtoNameToCppName( method_vars["longrunning_deduced_response_message_type"]); method_vars["method_longrunning_deduced_return_doxygen_link"] = - absl::visit(FormatDoxygenLinkVisitor{}, deduced_response_type); + std::visit(FormatDoxygenLinkVisitor{}, deduced_response_type); return; } if (IsHttpLongrunningOperation(method)) { - method_vars["longrunning_response_type"] = ProtoNameToCppName(absl::visit( + method_vars["longrunning_response_type"] = ProtoNameToCppName(std::visit( FullyQualifiedMessageTypeVisitor(), FullyQualifyMessageType( method, std::string{method.output_type()->full_name()}))); - absl::variant + std::variant deduced_response_type = method.output_type(); method_vars["longrunning_deduced_response_message_type"] = - absl::visit(FullyQualifiedMessageTypeVisitor(), deduced_response_type); + std::visit(FullyQualifiedMessageTypeVisitor(), deduced_response_type); method_vars["longrunning_deduced_response_type"] = ProtoNameToCppName( method_vars["longrunning_deduced_response_message_type"]); method_vars["method_longrunning_deduced_return_doxygen_link"] = - absl::visit(FormatDoxygenLinkVisitor{}, deduced_response_type); + std::visit(FormatDoxygenLinkVisitor{}, deduced_response_type); } } @@ -170,7 +170,7 @@ void SetLongrunningOperationServiceVars( } if (IsHttpLongrunningOperation(*method)) { service_vars["longrunning_response_type"] = - ProtoNameToCppName(absl::visit( + ProtoNameToCppName(std::visit( FullyQualifiedMessageTypeVisitor(), FullyQualifyMessageType( *method, std::string{method->output_type()->full_name()}))); diff --git a/google/cloud/bigquery/v2/minimal/internal/common_v2_resources.cc b/google/cloud/bigquery/v2/minimal/internal/common_v2_resources.cc index 1b2ef4c79af3e..154e3f4a17570 100644 --- a/google/cloud/bigquery/v2/minimal/internal/common_v2_resources.cc +++ b/google/cloud/bigquery/v2/minimal/internal/common_v2_resources.cc @@ -17,6 +17,7 @@ #include "google/cloud/internal/debug_string.h" #include "google/cloud/internal/format_time_point.h" #include "google/cloud/log.h" +#include namespace google { namespace cloud { @@ -148,7 +149,7 @@ void to_json(nlohmann::json& j, StandardSqlDataType const& t) { } }; - absl::visit(Visitor{t.type_kind, j}, t.sub_type); + std::visit(Visitor{t.type_kind, j}, t.sub_type); } void from_json(nlohmann::json const& j, StandardSqlDataType& t) { @@ -205,7 +206,7 @@ void to_json(nlohmann::json& j, Value const& v) { } }; - absl::visit(Visitor{j}, v.value_kind); + std::visit(Visitor{j}, v.value_kind); } void from_json(nlohmann::json const& j, Value& v) { @@ -493,7 +494,7 @@ std::string StandardSqlDataType::DebugString(absl::string_view name, std::string Value::DebugString(absl::string_view name, TracingOptions const& options, int indent) const { - return absl::visit(ValueKindDebugString{name, options, indent}, value_kind); + return std::visit(ValueKindDebugString{name, options, indent}, value_kind); } std::string SystemVariables::DebugString(absl::string_view name, diff --git a/google/cloud/bigtable/column_family.h b/google/cloud/bigtable/column_family.h index 28c898df25139..ea0868ca736ad 100644 --- a/google/cloud/bigtable/column_family.h +++ b/google/cloud/bigtable/column_family.h @@ -16,13 +16,13 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_COLUMN_FAMILY_H #include "google/cloud/bigtable/version.h" -#include "absl/meta/type_traits.h" #include "google/bigtable/admin/v2/bigtable_table_admin.pb.h" #include "google/bigtable/admin/v2/table.pb.h" #include #include #include #include +#include namespace google { namespace cloud { @@ -96,7 +96,7 @@ class GcRule { // letting the compiler figure things out N levels deep as it recurses on // `add_intersection()`. static_assert( - absl::conjunction...>::value, + std::conjunction...>::value, "The arguments to Intersection must be convertible to GcRule"); GcRule tmp; auto& intersection = *tmp.gc_rule_.mutable_intersection(); @@ -121,7 +121,7 @@ class GcRule { // letting the compiler figure things out N levels deep as it recurses on // `add_intersection()`. static_assert( - absl::conjunction...>::value, + std::conjunction...>::value, "The arguments to Union must be convertible to GcRule"); GcRule tmp; auto& gc_rule_union = *tmp.gc_rule_.mutable_union_(); diff --git a/google/cloud/bigtable/filters.h b/google/cloud/bigtable/filters.h index 5e93c549605cd..80413cc068bf7 100644 --- a/google/cloud/bigtable/filters.h +++ b/google/cloud/bigtable/filters.h @@ -16,11 +16,11 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_FILTERS_H #include "google/cloud/bigtable/version.h" -#include "absl/meta/type_traits.h" #include "google/bigtable/v2/data.pb.h" #include #include #include +#include namespace google { namespace cloud { @@ -572,7 +572,7 @@ class Filter { // just letting the compiler figure things out 3 levels deep // as it recurses on append_types(). static_assert( - absl::conjunction...>::value, + std::conjunction...>::value, "The arguments passed to Chain(...) must be convertible to Filter"); Filter tmp; auto& chain = *tmp.filter_.mutable_chain(); @@ -636,7 +636,7 @@ class Filter { template static Filter Interleave(FilterTypes&&... streams) { static_assert( - absl::conjunction...>::value, + std::conjunction...>::value, "The arguments passed to Interleave(...) must be convertible" " to Filter"); Filter tmp; diff --git a/google/cloud/bigtable/internal/default_row_reader.cc b/google/cloud/bigtable/internal/default_row_reader.cc index 12427521f514d..68d27cf5fb766 100644 --- a/google/cloud/bigtable/internal/default_row_reader.cc +++ b/google/cloud/bigtable/internal/default_row_reader.cc @@ -18,6 +18,7 @@ #include "google/cloud/grpc_options.h" #include "google/cloud/internal/make_status.h" #include "google/cloud/internal/retry_loop_helpers.h" +#include namespace google { namespace cloud { @@ -107,12 +108,12 @@ absl::variant DefaultRowReader::Advance() { } while (true) { auto variant = AdvanceOrFail(); - if (absl::holds_alternative(variant)) { + if (std::holds_alternative(variant)) { operation_context_->ElementDelivery(*client_context_); - return absl::get(std::move(variant)); + return std::get(std::move(variant)); } - auto status = absl::get(std::move(variant)); + auto status = std::get(std::move(variant)); if (status.ok()) return Status{}; // In the unlikely case when we have already reached the requested diff --git a/google/cloud/bigtable/mutations.h b/google/cloud/bigtable/mutations.h index 642fe4969e299..4ed555f9478b1 100644 --- a/google/cloud/bigtable/mutations.h +++ b/google/cloud/bigtable/mutations.h @@ -22,7 +22,6 @@ #include "google/cloud/internal/big_endian.h" #include "google/cloud/status.h" #include "google/cloud/status_or.h" -#include "absl/meta/type_traits.h" #include "google/bigtable/v2/bigtable.pb.h" #include "google/bigtable/v2/data.pb.h" #include @@ -325,7 +324,7 @@ class SingleRowMutation { > explicit SingleRowMutation(RowKey&& row_key, M&&... m) { static_assert( - absl::conjunction...>::value, + std::conjunction...>::value, "The arguments passed to SingleRowMutation(std::string, ...) must be " "convertible to Mutation"); request_.set_row_key(std::forward(row_key)); @@ -523,7 +522,7 @@ class BulkMutation { /// Create a multi-row mutation from a variadic list. template ...>::value, int> = 0 /// @endcond diff --git a/google/cloud/bigtable/table.h b/google/cloud/bigtable/table.h index 19a7c35deb678..e785953243265 100644 --- a/google/cloud/bigtable/table.h +++ b/google/cloud/bigtable/table.h @@ -40,8 +40,8 @@ #include "google/cloud/options.h" #include "google/cloud/status.h" #include "google/cloud/status_or.h" -#include "absl/meta/type_traits.h" #include +#include #include namespace google { @@ -157,13 +157,13 @@ class Table { /// A meta function to check if @p P is a valid Policy type. template struct ValidPolicy - : absl::disjunction, - std::is_base_of, - std::is_base_of> {}; + : std::disjunction, + std::is_base_of, + std::is_base_of> {}; /// A meta function to check if all the @p Policies are valid policy types. template - struct ValidPolicies : absl::conjunction...> {}; + struct ValidPolicies : std::conjunction...> {}; public: /** @@ -589,7 +589,7 @@ class Table { // Generate a better compile time error message than the default one // if the types do not match static_assert( - absl::conjunction, std::is_same, Options>>...>::value, "The arguments passed to ReadModifyWriteRow(row_key,...) must be " @@ -643,7 +643,7 @@ class Table { // Generate a better compile time error message than the default one // if the types do not match static_assert( - absl::conjunction, std::is_same, Options>>...>::value, "The arguments passed to AsyncReadModifyWriteRow(row_key,...) must be " diff --git a/google/cloud/bigtable/value_test.cc b/google/cloud/bigtable/value_test.cc index 3ac6792e92c1e..2c911534fe475 100644 --- a/google/cloud/bigtable/value_test.cc +++ b/google/cloud/bigtable/value_test.cc @@ -305,7 +305,7 @@ template < std::is_same>, absl::Cord>::value>::type* = nullptr, typename std::enable_if_t< - absl::disjunction, + std::disjunction, std::is_same>>::value, int> = 0> diff --git a/google/cloud/future_generic.h b/google/cloud/future_generic.h index 4c3049dd4d6c2..ad3a014d5787d 100644 --- a/google/cloud/future_generic.h +++ b/google/cloud/future_generic.h @@ -20,7 +20,6 @@ #include "google/cloud/internal/future_impl.h" #include "google/cloud/internal/invoke_result.h" #include "google/cloud/version.h" -#include "absl/meta/type_traits.h" #include #include @@ -64,7 +63,7 @@ class future final : private internal::future_base { * future's result type. */ template ::value>> + std::enable_if_t::value>> explicit future(future&& rhs); /** diff --git a/google/cloud/internal/future_impl.h b/google/cloud/internal/future_impl.h index 23fb11151f795..31fdc20cf7aea 100644 --- a/google/cloud/internal/future_impl.h +++ b/google/cloud/internal/future_impl.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace google { namespace cloud { @@ -222,7 +223,7 @@ class future_shared_state final { // NOLINT(readability-identifier-naming) // future, so new calls will fail. ValueType tmp(FutureValueRetrieved{}); tmp.swap(value_); - return absl::visit(Visitor{}, std::move(tmp)); + return std::visit(Visitor{}, std::move(tmp)); } /** @@ -421,7 +422,7 @@ class future_shared_state final { // NOLINT(readability-identifier-naming) protected: bool is_ready_unlocked() const { - return !absl::holds_alternative(value_); + return !std::holds_alternative(value_); } /// Satisfy the shared state using an exception. diff --git a/google/cloud/internal/future_then_impl.h b/google/cloud/internal/future_then_impl.h index a73fe09aa8752..4344e29a6e23b 100644 --- a/google/cloud/internal/future_then_impl.h +++ b/google/cloud/internal/future_then_impl.h @@ -22,6 +22,7 @@ #include "absl/functional/function_ref.h" #include #include +#include namespace google { namespace cloud { @@ -104,7 +105,7 @@ struct FutureThenImpl { void operator()(FutureValueRetrieved) { output->abandon(); } void operator()(T v) { set_value(*output, std::move(v)); } }; - return absl::visit(Visitor{std::move(output_)}, s.value()); + return std::visit(Visitor{std::move(output_)}, s.value()); } private: @@ -140,7 +141,7 @@ struct FutureThenImpl { unwrap(std::move(output), std::move(v.shared_state_)); } }; - return absl::visit(Visitor{std::move(output_)}, s.value()); + return std::visit(Visitor{std::move(output_)}, s.value()); } private: diff --git a/google/cloud/internal/type_list.h b/google/cloud/internal/type_list.h index caaa771e526f3..23100126dc9fe 100644 --- a/google/cloud/internal/type_list.h +++ b/google/cloud/internal/type_list.h @@ -16,7 +16,6 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TYPE_LIST_H #include "google/cloud/version.h" -#include "absl/meta/type_traits.h" #include #include #include @@ -93,7 +92,7 @@ struct TypeListHasType; template struct TypeListHasType, T> - : absl::disjunction...> {}; + : std::disjunction...> {}; template