Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions generator/internal/http_annotation_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "absl/strings/str_cat.h"
#include <cassert>
#include <functional>
#include <variant>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -246,7 +247,7 @@ StatusOr<PathTemplate> ParsePathTemplate(absl::string_view input) {
return MakeParseError(input, v->end, " end of input", GCP_ERROR_INFO());
}
return PathTemplate{std::move(s->value),
absl::get<std::string>(v->value.value)};
std::get<std::string>(v->value.value)};
}

std::ostream& operator<<(std::ostream& os, PathTemplate::Segment const& rhs) {
Expand All @@ -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;
}
Expand Down
15 changes: 8 additions & 7 deletions generator/internal/http_annotation_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <gmock/gmock.h>
#include <algorithm>
#include <sstream>
#include <variant>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -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<PathTemplate::Match>(a.value);
return std::holds_alternative<PathTemplate::Match>(a.value);
}
bool operator()(PathTemplate::MatchRecursive const&) {
return absl::holds_alternative<PathTemplate::MatchRecursive>(a.value);
return std::holds_alternative<PathTemplate::MatchRecursive>(a.value);
}
bool operator()(std::string const& s) {
return absl::holds_alternative<std::string>(a.value) &&
absl::get<std::string>(a.value) == s;
return std::holds_alternative<std::string>(a.value) &&
std::get<std::string>(a.value) == s;
}
bool operator()(PathTemplate::Variable const& v) {
return absl::holds_alternative<PathTemplate::Variable>(a.value) &&
SameValues(absl::get<PathTemplate::Variable>(a.value), v);
return std::holds_alternative<PathTemplate::Variable>(a.value) &&
SameValues(std::get<PathTemplate::Variable>(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) {
Expand Down
11 changes: 6 additions & 5 deletions generator/internal/http_option_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <google/protobuf/descriptor.h>
#include <optional>
#include <regex>
#include <variant>
#include <vector>

using ::google::protobuf::MethodDescriptor;
Expand Down Expand Up @@ -96,7 +97,7 @@ struct RestPathVisitor {
void RestPathVisitorHelper(
std::optional<std::string> api_version, PathTemplate::Segment const& s,
std::vector<HttpExtensionInfo::RestPathPiece>& path) {
absl::visit(RestPathVisitor{std::move(api_version), path}, s.value);
std::visit(RestPathVisitor{std::move(api_version), path}, s.value);
}

std::string FormatQueryParameterCode(
Expand Down Expand Up @@ -319,15 +320,15 @@ HttpExtensionInfo ParseHttpExtension(google::api::HttpRule const& http_rule) {
};
auto segment_formatter = [](std::string* out,
std::shared_ptr<PathTemplate::Segment> 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<PathTemplate::Variable>(s->value)) {
auto v = absl::get<PathTemplate::Variable>(s->value);
if (std::holds_alternative<PathTemplate::Variable>(s->value)) {
auto v = std::get<PathTemplate::Variable>(s->value);
if (v.segments.empty()) {
info.field_substitutions.emplace_back(v.field_path, v.field_path);
} else {
Expand All @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions generator/internal/longrunning.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#include <variant>

using ::google::protobuf::Descriptor;
using ::google::protobuf::MethodDescriptor;
Expand All @@ -31,7 +31,7 @@ namespace cloud {
namespace generator_internal {
namespace {

absl::variant<std::string, Descriptor const*> FullyQualifyMessageType(
std::variant<std::string, Descriptor const*> FullyQualifyMessageType(
MethodDescriptor const& method, std::string message_type) {
Descriptor const* output_type =
method.file()->pool()->FindMessageTypeByName(message_type);
Expand Down Expand Up @@ -63,7 +63,7 @@ struct FormatDoxygenLinkVisitor {
}
};

absl::variant<std::string, Descriptor const*>
std::variant<std::string, Descriptor const*>
DeduceLongrunningOperationResponseType(
MethodDescriptor const& method,
google::longrunning::OperationInfo const& operation_info) {
Expand Down Expand Up @@ -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::string, google::protobuf::Descriptor const*>
std::variant<std::string, google::protobuf::Descriptor const*>
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);
}
}

Expand Down Expand Up @@ -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()})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <variant>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigtable/column_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <google/protobuf/util/message_differencer.h>
#include <chrono>
#include <memory>
#include <string>
#include <type_traits>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -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<std::is_convertible<GcRuleTypes, GcRule>...>::value,
std::conjunction<std::is_convertible<GcRuleTypes, GcRule>...>::value,
"The arguments to Intersection must be convertible to GcRule");
GcRule tmp;
auto& intersection = *tmp.gc_rule_.mutable_intersection();
Expand All @@ -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<std::is_convertible<GcRuleTypes, GcRule>...>::value,
std::conjunction<std::is_convertible<GcRuleTypes, GcRule>...>::value,
"The arguments to Union must be convertible to GcRule");
GcRule tmp;
auto& gc_rule_union = *tmp.gc_rule_.mutable_union_();
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigtable/filters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <google/protobuf/util/message_differencer.h>
#include <chrono>
#include <string>
#include <type_traits>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -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<std::is_convertible<FilterTypes, Filter>...>::value,
std::conjunction<std::is_convertible<FilterTypes, Filter>...>::value,
"The arguments passed to Chain(...) must be convertible to Filter");
Filter tmp;
auto& chain = *tmp.filter_.mutable_chain();
Expand Down Expand Up @@ -636,7 +636,7 @@ class Filter {
template <typename... FilterTypes>
static Filter Interleave(FilterTypes&&... streams) {
static_assert(
absl::conjunction<std::is_convertible<FilterTypes, Filter>...>::value,
std::conjunction<std::is_convertible<FilterTypes, Filter>...>::value,
"The arguments passed to Interleave(...) must be convertible"
" to Filter");
Filter tmp;
Expand Down
7 changes: 4 additions & 3 deletions google/cloud/bigtable/internal/default_row_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <variant>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -107,12 +108,12 @@ absl::variant<Status, bigtable::Row> DefaultRowReader::Advance() {
}
while (true) {
auto variant = AdvanceOrFail();
if (absl::holds_alternative<bigtable::Row>(variant)) {
if (std::holds_alternative<bigtable::Row>(variant)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The return type of DefaultRowReader::Advance() (and potentially AdvanceOrFail()) still appears to be absl::variant (as seen in the hunk header). If AdvanceOrFail() returns absl::variant, using std::holds_alternative and std::get on it will fail to compile. Please ensure that the return types of both Advance() and AdvanceOrFail() are also migrated to std::variant in the corresponding header and source files to fully adhere to the style guide.

References
  1. Use std::variant instead of absl::variant. (link)

operation_context_->ElementDelivery(*client_context_);
return absl::get<bigtable::Row>(std::move(variant));
return std::get<bigtable::Row>(std::move(variant));
}

auto status = absl::get<Status>(std::move(variant));
auto status = std::get<Status>(std::move(variant));
if (status.ok()) return Status{};

// In the unlikely case when we have already reached the requested
Expand Down
5 changes: 2 additions & 3 deletions google/cloud/bigtable/mutations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <google/protobuf/util/message_differencer.h>
Expand Down Expand Up @@ -325,7 +324,7 @@ class SingleRowMutation {
>
explicit SingleRowMutation(RowKey&& row_key, M&&... m) {
static_assert(
absl::conjunction<std::is_convertible<M, Mutation>...>::value,
std::conjunction<std::is_convertible<M, Mutation>...>::value,
"The arguments passed to SingleRowMutation(std::string, ...) must be "
"convertible to Mutation");
request_.set_row_key(std::forward<RowKey>(row_key));
Expand Down Expand Up @@ -523,7 +522,7 @@ class BulkMutation {
/// Create a multi-row mutation from a variadic list.
template <typename... M,
/// @cond implementation_details
std::enable_if_t<absl::conjunction<std::is_convertible<
std::enable_if_t<std::conjunction<std::is_convertible<
M, SingleRowMutation>...>::value,
int> = 0
/// @endcond
Expand Down
14 changes: 7 additions & 7 deletions google/cloud/bigtable/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#include <type_traits>
#include <vector>

namespace google {
Expand Down Expand Up @@ -157,13 +157,13 @@ class Table {
/// A meta function to check if @p P is a valid Policy type.
template <typename P>
struct ValidPolicy
: absl::disjunction<std::is_base_of<RPCBackoffPolicy, P>,
std::is_base_of<RPCRetryPolicy, P>,
std::is_base_of<IdempotentMutationPolicy, P>> {};
: std::disjunction<std::is_base_of<RPCBackoffPolicy, P>,
std::is_base_of<RPCRetryPolicy, P>,
std::is_base_of<IdempotentMutationPolicy, P>> {};

/// A meta function to check if all the @p Policies are valid policy types.
template <typename... Policies>
struct ValidPolicies : absl::conjunction<ValidPolicy<Policies>...> {};
struct ValidPolicies : std::conjunction<ValidPolicy<Policies>...> {};

public:
/**
Expand Down Expand Up @@ -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<absl::disjunction<
std::conjunction<std::disjunction<
std::is_convertible<Args, bigtable::ReadModifyWriteRule>,
std::is_same<std::decay_t<Args>, Options>>...>::value,
"The arguments passed to ReadModifyWriteRow(row_key,...) must be "
Expand Down Expand Up @@ -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<absl::disjunction<
std::conjunction<std::disjunction<
std::is_convertible<Args, bigtable::ReadModifyWriteRule>,
std::is_same<std::decay_t<Args>, Options>>...>::value,
"The arguments passed to AsyncReadModifyWriteRow(row_key,...) must be "
Expand Down
Loading
Loading