Skip to content
Merged
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
3 changes: 2 additions & 1 deletion examples/api_key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "absl/strings/str_split.h"
#include <chrono>
#include <iostream>
#include <optional>
#include <string>
#include <thread>
#include <vector>
Expand Down Expand Up @@ -147,7 +148,7 @@ void AutoRun(std::vector<std::string> const& argv) {
// When we authenticate with an API key, we do not have (or need)
// credentials. Using a quota project requires credentials, so disable it.
google::cloud::testing_util::ScopedEnvironment overlay(
"GOOGLE_CLOUD_CPP_USER_PROJECT", absl::nullopt);
"GOOGLE_CLOUD_CPP_USER_PROJECT", std::nullopt);

try {
AuthenticateWithApiKey({project_id, key.key_string()});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ StreamRange<google::test::admin::database::v1::Response> GoldenKitchenSinkConnec
google::test::admin::database::v1::Request const&) {
return google::cloud::internal::MakeStreamRange<
google::test::admin::database::v1::Response>(
[]() -> absl::variant<Status,
[]() -> std::variant<Status,
google::test::admin::database::v1::Response>{
return Status(StatusCode::kUnimplemented, "not implemented");}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ GoldenKitchenSinkConnectionImpl::StreamingRead(google::test::admin::database::v1
GoldenKitchenSinkStreamingReadStreamingUpdater, request);
return internal::MakeStreamRange<google::test::admin::database::v1::Response>(
[resumable = std::move(resumable)]()
-> absl::variant<
-> std::variant<
Status,
google::test::admin::database::v1::Response> {
google::test::admin::database::v1::Response response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ GoldenKitchenSinkMetadata::ExplicitRouting1(
{[](google::test::admin::database::v1::ExplicitRoutingRequest const& request) -> std::string const& {
return request.app_profile_id();
},
absl::nullopt},
std::nullopt},
{[](google::test::admin::database::v1::ExplicitRoutingRequest const& request) -> std::string const& {
return request.table_name();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ GoldenKitchenSinkRestMetadata::ExplicitRouting1(
{[](google::test::admin::database::v1::ExplicitRoutingRequest const& request) -> std::string const& {
return request.app_profile_id();
},
absl::nullopt},
std::nullopt},
{[](google::test::admin::database::v1::ExplicitRoutingRequest const& request) -> std::string const& {
return request.table_name();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TEST(GoldenKitchenSinkClientTest, StreamingRead) {
Contains("test-only/1.0"));
EXPECT_THAT(request.stream(), "test-only-stream-name");
return google::cloud::internal::MakeStreamRange<Response>(
[]() -> absl::variant<Status, Response> {
[]() -> std::variant<Status, Response> {
return Status(StatusCode::kPermissionDenied, "uh-oh");
});
});
Expand Down
2 changes: 1 addition & 1 deletion generator/internal/connection_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
" $request_type$ const&) {\n"
" return google::cloud::internal::MakeStreamRange<\n"
" $response_type$>(\n"
" []() -> absl::variant<Status,\n"
" []() -> std::variant<Status,\n"
" $response_type$>{\n"
" return Status(StatusCode::kUnimplemented, \"not implemented\");}\n"
" );\n"
Expand Down
2 changes: 1 addition & 1 deletion generator/internal/connection_impl_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ StreamRange<$response_type$>
$service_name$$method_name$StreamingUpdater, request);
return internal::MakeStreamRange<$response_type$>(
[resumable = std::move(resumable)]()
-> absl::variant<
-> std::variant<
Status,
$response_type$> {
$response_type$ response;
Expand Down
1 change: 0 additions & 1 deletion generator/internal/descriptor_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/strip.h"
#include "absl/types/variant.h"
#include "google/api/annotations.pb.h"
#include "google/api/http.pb.h"
#include "google/api/routing.pb.h"
Expand Down
1 change: 0 additions & 1 deletion generator/internal/descriptor_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "generator/internal/mixin_utils.h"
#include "generator/internal/predicate_utils.h"
#include "generator/internal/printer.h"
#include "absl/types/variant.h"
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/descriptor.h>
#include <yaml-cpp/yaml.h>
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
4 changes: 2 additions & 2 deletions generator/internal/http_annotation_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "google/cloud/status_or.h"
#include "absl/strings/string_view.h"
#include "absl/types/variant.h"
#include <memory>
#include <variant>
#include <vector>

namespace google {
Expand Down Expand Up @@ -86,7 +86,7 @@ struct PathTemplate {
std::vector<std::shared_ptr<Segment>> segments;
};
struct Segment {
absl::variant<Match, MatchRecursive, std::string, Variable> value;
std::variant<Match, MatchRecursive, std::string, Variable> value;
};
using Segments = std::vector<std::shared_ptr<Segment>>;

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);
Comment thread
scotthart marked this conversation as resolved.
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
31 changes: 15 additions & 16 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 @@ -169,11 +169,10 @@ void SetLongrunningOperationServiceVars(
return;
}
if (IsHttpLongrunningOperation(*method)) {
service_vars["longrunning_response_type"] =
ProtoNameToCppName(absl::visit(
FullyQualifiedMessageTypeVisitor(),
FullyQualifyMessageType(
*method, std::string{method->output_type()->full_name()})));
service_vars["longrunning_response_type"] = ProtoNameToCppName(std::visit(
FullyQualifiedMessageTypeVisitor(),
FullyQualifyMessageType(
*method, std::string{method->output_type()->full_name()})));
auto operation_service_extension =
method->options().GetExtension(google::cloud::operation_service);

Expand Down
2 changes: 1 addition & 1 deletion generator/internal/metadata_decorator_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ std::string SetMetadataText(google::protobuf::MethodDescriptor const& method,
text += " },\n";
// In the special match-all case, we do not bother to set a regex.
if (rp.pattern == "(.*)") {
text += " absl::nullopt},\n";
text += " std::nullopt},\n";
} else {
text += " std::regex{\"" + rp.pattern + "\", std::regex::optimize}},\n";
}
Expand Down
2 changes: 1 addition & 1 deletion generator/internal/metadata_decorator_rest_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ std::string SetMetadataText(google::protobuf::MethodDescriptor const& method,
text += " },\n";
// In the special match-all case, we do not bother to set a regex.
if (rp.pattern == "(.*)") {
text += " absl::nullopt},\n";
text += " std::nullopt},\n";
} else {
text += " std::regex{\"" + rp.pattern + "\", std::regex::optimize}},\n";
}
Expand Down
1 change: 0 additions & 1 deletion google/cloud/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ cc_library(
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/time",
"@abseil-cpp//absl/types:span",
"@abseil-cpp//absl/types:variant",
"@opentelemetry-cpp//api",
] + select({
"@platforms//os:windows": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FeaturestoreOnlineServingServiceConnection::StreamingReadFeatureValues(
google::cloud::aiplatform::v1::StreamingReadFeatureValuesRequest const&) {
return google::cloud::internal::MakeStreamRange<
google::cloud::aiplatform::v1::ReadFeatureValuesResponse>(
[]() -> absl::variant<
[]() -> std::variant<
Status,
google::cloud::aiplatform::v1::ReadFeatureValuesResponse> {
return Status(StatusCode::kUnimplemented, "not implemented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ FeaturestoreOnlineServingServiceConnectionImpl::StreamingReadFeatureValues(
return internal::MakeStreamRange<
google::cloud::aiplatform::v1::ReadFeatureValuesResponse>(
[resumable = std::move(resumable)]()
-> absl::variant<
-> std::variant<
Status,
google::cloud::aiplatform::v1::ReadFeatureValuesResponse> {
google::cloud::aiplatform::v1::ReadFeatureValuesResponse response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ PredictionServiceConnectionImpl::StreamRawPredict(
PredictionServiceStreamRawPredictStreamingUpdater, request);
return internal::MakeStreamRange<google::api::HttpBody>(
[resumable = std::move(
resumable)]() -> absl::variant<Status, google::api::HttpBody> {
resumable)]() -> std::variant<Status, google::api::HttpBody> {
google::api::HttpBody response;
auto status = resumable->Read(&response);
if (status.has_value()) return *status;
Expand Down Expand Up @@ -204,7 +204,7 @@ PredictionServiceConnectionImpl::ServerStreamingPredict(
return internal::MakeStreamRange<
google::cloud::aiplatform::v1::StreamingPredictResponse>(
[resumable = std::move(resumable)]()
-> absl::variant<
-> std::variant<
Status, google::cloud::aiplatform::v1::StreamingPredictResponse> {
google::cloud::aiplatform::v1::StreamingPredictResponse response;
auto status = resumable->Read(&response);
Expand Down Expand Up @@ -270,7 +270,7 @@ PredictionServiceConnectionImpl::StreamGenerateContent(
return internal::MakeStreamRange<
google::cloud::aiplatform::v1::GenerateContentResponse>(
[resumable = std::move(resumable)]()
-> absl::variant<
-> std::variant<
Status, google::cloud::aiplatform::v1::GenerateContentResponse> {
google::cloud::aiplatform::v1::GenerateContentResponse response;
auto status = resumable->Read(&response);
Expand Down
Loading
Loading