diff --git a/google/cloud/BUILD.bazel b/google/cloud/BUILD.bazel index dd4feee33dcf0..725b45a88055f 100644 --- a/google/cloud/BUILD.bazel +++ b/google/cloud/BUILD.bazel @@ -77,7 +77,6 @@ cc_library( "@abseil-cpp//absl/strings", "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/time", - "@abseil-cpp//absl/types:optional", "@abseil-cpp//absl/types:span", "@abseil-cpp//absl/types:variant", "@opentelemetry-cpp//api", diff --git a/google/cloud/async_streaming_read_write_rpc.h b/google/cloud/async_streaming_read_write_rpc.h index c16624ac8c53a..9c920778bc361 100644 --- a/google/cloud/async_streaming_read_write_rpc.h +++ b/google/cloud/async_streaming_read_write_rpc.h @@ -19,8 +19,8 @@ #include "google/cloud/rpc_metadata.h" #include "google/cloud/status.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include +#include namespace google { namespace cloud { @@ -77,7 +77,7 @@ class AsyncStreamingReadWriteRpc { * other `Write()` calls) complete and then call `Finish()` to find the status * of the streaming RPC. */ - virtual future> Read() = 0; + virtual future> Read() = 0; /** * Write one request to the streaming RPC. diff --git a/google/cloud/credentials.cc b/google/cloud/credentials.cc index 490a6f2f5d547..22ccd8ddfcc64 100644 --- a/google/cloud/credentials.cc +++ b/google/cloud/credentials.cc @@ -48,13 +48,13 @@ std::shared_ptr MakeImpersonateServiceAccountCredentials( std::shared_ptr MakeServiceAccountCredentials( std::string json_object, Options opts) { return std::make_shared( - std::move(json_object), absl::nullopt, std::move(opts)); + std::move(json_object), std::nullopt, std::move(opts)); } std::shared_ptr MakeServiceAccountCredentialsFromFile( std::string const& file_path, Options opts) { return std::make_shared( - absl::nullopt, file_path, std::move(opts)); + std::nullopt, file_path, std::move(opts)); } std::shared_ptr MakeExternalAccountCredentials( diff --git a/google/cloud/grpc_error_delegate.cc b/google/cloud/grpc_error_delegate.cc index fcda02086e17c..6ef831c916097 100644 --- a/google/cloud/grpc_error_delegate.cc +++ b/google/cloud/grpc_error_delegate.cc @@ -14,10 +14,10 @@ #include "google/cloud/grpc_error_delegate.h" #include "google/cloud/internal/status_payload_keys.h" -#include "absl/types/optional.h" #include "google/protobuf/any.pb.h" #include "google/rpc/error_details.pb.h" #include +#include namespace google { namespace cloud { @@ -67,7 +67,7 @@ google::cloud::StatusCode MapStatusCode(grpc::StatusCode const& code) { } // Unpacks the ErrorInfo from the Status proto, if one exists. -absl::optional GetErrorInfoProto( +std::optional GetErrorInfoProto( google::rpc::Status const& proto) { // While in theory there _could_ be multiple ErrorInfo protos in this // repeated field, we're told that there will be at most one, and our @@ -76,7 +76,7 @@ absl::optional GetErrorInfoProto( for (google::protobuf::Any const& any : proto.details()) { if (any.UnpackTo(&error_info)) return error_info; } - return absl::nullopt; + return std::nullopt; } ErrorInfo GetErrorInfo(google::rpc::Status const& status) { @@ -88,7 +88,7 @@ ErrorInfo GetErrorInfo(google::rpc::Status const& status) { } // Unpacks the RetryInfo from the Status proto, if one exists. -absl::optional GetRetryInfo( +std::optional GetRetryInfo( google::rpc::Status const& proto) { // While in theory there _could_ be multiple RetryInfo protos in this // repeated field, we're told that there will be at most one, and our @@ -101,7 +101,7 @@ absl::optional GetRetryInfo( return internal::RetryInfo(d); } } - return absl::nullopt; + return std::nullopt; } } // namespace diff --git a/google/cloud/grpc_error_delegate_test.cc b/google/cloud/grpc_error_delegate_test.cc index 3c8c80991fa20..1b96d428b363e 100644 --- a/google/cloud/grpc_error_delegate_test.cc +++ b/google/cloud/grpc_error_delegate_test.cc @@ -133,7 +133,7 @@ TEST(MakeStatusFromRpcError, AllCodesWithPayload) { EXPECT_EQ(expected, actual); EXPECT_EQ(message, actual.message()); EXPECT_EQ(ErrorInfo{}, actual.error_info()); - EXPECT_EQ(absl::nullopt, internal::GetRetryInfo(actual)); + EXPECT_EQ(std::nullopt, internal::GetRetryInfo(actual)); // Make sure the actual payload is what we expect. auto actual_payload = google::cloud::internal::GetPayload( diff --git a/google/cloud/grpc_options.cc b/google/cloud/grpc_options.cc index 322bf2cc57213..9b337ef2369a6 100644 --- a/google/cloud/grpc_options.cc +++ b/google/cloud/grpc_options.cc @@ -118,30 +118,30 @@ grpc::ChannelArguments MakeChannelArguments(Options const& opts) { return channel_arguments; } -absl::optional GetIntChannelArgument(grpc::ChannelArguments const& args, +std::optional GetIntChannelArgument(grpc::ChannelArguments const& args, std::string const& key) { auto c_args = args.c_channel_args(); // Just do a linear search for the key; the data structure is not organized // in any other useful way. for (auto const* a = c_args.args; a != c_args.args + c_args.num_args; ++a) { if (key != a->key) continue; - if (a->type != GRPC_ARG_INTEGER) return absl::nullopt; + if (a->type != GRPC_ARG_INTEGER) return std::nullopt; return a->value.integer; } - return absl::nullopt; + return std::nullopt; } -absl::optional GetStringChannelArgument( +std::optional GetStringChannelArgument( grpc::ChannelArguments const& args, std::string const& key) { auto c_args = args.c_channel_args(); // Just do a linear search for the key; the data structure is not organized // in any other useful way. for (auto const* a = c_args.args; a != c_args.args + c_args.num_args; ++a) { if (key != a->key) continue; - if (a->type != GRPC_ARG_STRING) return absl::nullopt; + if (a->type != GRPC_ARG_STRING) return std::nullopt; return a->value.string; } - return absl::nullopt; + return std::nullopt; } BackgroundThreadsFactory MakeBackgroundThreadsFactory(Options const& opts) { diff --git a/google/cloud/grpc_options.h b/google/cloud/grpc_options.h index 8f84366b7a2bb..90c631780e36d 100644 --- a/google/cloud/grpc_options.h +++ b/google/cloud/grpc_options.h @@ -258,11 +258,11 @@ std::string MakeGrpcHttpProxy(ProxyConfig const& config); grpc::ChannelArguments MakeChannelArguments(Options const& opts); /// Helper function to extract the first instance of an integer channel argument -absl::optional GetIntChannelArgument(grpc::ChannelArguments const& args, +std::optional GetIntChannelArgument(grpc::ChannelArguments const& args, std::string const& key); /// Helper function to extract the first instance of a string channel argument -absl::optional GetStringChannelArgument( +std::optional GetStringChannelArgument( grpc::ChannelArguments const& args, std::string const& key); /** diff --git a/google/cloud/iam_updater.h b/google/cloud/iam_updater.h index 6914b6c273c8c..b04713268add4 100644 --- a/google/cloud/iam_updater.h +++ b/google/cloud/iam_updater.h @@ -16,9 +16,9 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_UPDATER_H #include "google/cloud/version.h" -#include "absl/types/optional.h" #include "google/iam/v1/policy.pb.h" #include +#include namespace google { namespace cloud { @@ -38,7 +38,7 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN * has been an intermediate update), this update is dropped and a new cycle is * initiated. In case (2) the existing policy is overwritten blindly. */ -using IamUpdater = std::function( +using IamUpdater = std::function( google::iam::v1::Policy)>; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_read_write_stream_auth.h b/google/cloud/internal/async_read_write_stream_auth.h index 73a05a7d27991..4c7bc6e91c607 100644 --- a/google/cloud/internal/async_read_write_stream_auth.h +++ b/google/cloud/internal/async_read_write_stream_auth.h @@ -55,7 +55,7 @@ class AsyncStreamingReadWriteRpcAuth }); } - future> Read() override { + future> Read() override { std::lock_guard g{state_->mu}; return state_->stream->Read(); } diff --git a/google/cloud/internal/async_read_write_stream_auth_test.cc b/google/cloud/internal/async_read_write_stream_auth_test.cc index 891ca221d2ca9..06aef7e66f343 100644 --- a/google/cloud/internal/async_read_write_stream_auth_test.cc +++ b/google/cloud/internal/async_read_write_stream_auth_test.cc @@ -57,7 +57,7 @@ TEST(AsyncStreamReadWriteAuth, Start) { return make_ready_future(true); }); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::make_optional(FakeResponse{"k0", "v0"})); + return make_ready_future(std::make_optional(FakeResponse{"k0", "v0"})); }); EXPECT_CALL(*mock, WritesDone).WillOnce([] { return make_ready_future(true); diff --git a/google/cloud/internal/async_read_write_stream_impl.h b/google/cloud/internal/async_read_write_stream_impl.h index 22bd1b68ea4d1..d996d35e105e8 100644 --- a/google/cloud/internal/async_read_write_stream_impl.h +++ b/google/cloud/internal/async_read_write_stream_impl.h @@ -24,9 +24,9 @@ #include "google/cloud/options.h" #include "google/cloud/version.h" #include "absl/functional/function_ref.h" -#include "absl/types/optional.h" #include #include +#include #include namespace google { @@ -76,7 +76,7 @@ class AsyncStreamingReadWriteRpcImpl return op->p.get_future(); } - future> Read() override { + future> Read() override { struct OnRead : public AsyncGrpcOperation { explicit OnRead(ImmutableOptions o) : call_context(std::move(o)) {} @@ -91,7 +91,7 @@ class AsyncStreamingReadWriteRpcImpl } void Cancel() override {} - promise> p; + promise> p; Response response; CallContext call_context; }; @@ -223,8 +223,8 @@ class AsyncStreamingReadWriteRpcError void Cancel() override {} future Start() override { return make_ready_future(false); } - future> Read() override { - return make_ready_future>(absl::nullopt); + future> Read() override { + return make_ready_future>(std::nullopt); } future Write(Request const&, grpc::WriteOptions) override { return make_ready_future(false); diff --git a/google/cloud/internal/async_read_write_stream_logging.h b/google/cloud/internal/async_read_write_stream_logging.h index e5c0ca730ef28..73210c63c7b59 100644 --- a/google/cloud/internal/async_read_write_stream_logging.h +++ b/google/cloud/internal/async_read_write_stream_logging.h @@ -51,12 +51,12 @@ class AsyncStreamingReadWriteRpcLogging }); } - future> Read() override { + future> Read() override { auto prefix = std::string(__func__) + "(" + request_id_ + ")"; auto const& opt = tracing_options_; GCP_LOG(DEBUG) << prefix << " <<"; return child_->Read().then( - [prefix, opt](future> f) { + [prefix, opt](future> f) { auto r = f.get(); if (r.has_value()) { GCP_LOG(DEBUG) << prefix << " >> " << DebugString(*r, opt); diff --git a/google/cloud/internal/async_read_write_stream_logging_test.cc b/google/cloud/internal/async_read_write_stream_logging_test.cc index f481505262ef3..b175d8717ebc4 100644 --- a/google/cloud/internal/async_read_write_stream_logging_test.cc +++ b/google/cloud/internal/async_read_write_stream_logging_test.cc @@ -67,7 +67,7 @@ TEST_F(StreamingReadRpcLoggingTest, Start) { TEST_F(StreamingReadRpcLoggingTest, ReadWithValue) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::make_optional(google::protobuf::Duration{})); + return make_ready_future(std::make_optional(google::protobuf::Duration{})); }); TestedStream stream(std::move(mock), TracingOptions{}, "test-id"); EXPECT_TRUE(stream.Read().get().has_value()); @@ -79,7 +79,7 @@ TEST_F(StreamingReadRpcLoggingTest, ReadWithValue) { TEST_F(StreamingReadRpcLoggingTest, ReadWithout) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::optional{}); + return make_ready_future(std::optional{}); }); TestedStream stream(std::move(mock), TracingOptions{}, "test-id"); ASSERT_FALSE(stream.Read().get().has_value()); diff --git a/google/cloud/internal/async_read_write_stream_timeout.h b/google/cloud/internal/async_read_write_stream_timeout.h index d0392a9062664..ed304b165764c 100644 --- a/google/cloud/internal/async_read_write_stream_timeout.h +++ b/google/cloud/internal/async_read_write_stream_timeout.h @@ -66,7 +66,7 @@ class AsyncStreamingReadWriteRpcTimeout future Start() override { return state_->Start(); } - future> Read() override { return state_->Read(); } + future> Read() override { return state_->Read(); } future Write(Request const& request, grpc::WriteOptions options) override { @@ -117,23 +117,23 @@ class AsyncStreamingReadWriteRpcTimeout }); } - future> Read() { + future> Read() { auto watchdog = CreateWatchdog(per_read_timeout); return child->Read().then( [wd = std::move(watchdog), w = WeakFromThis()](auto f) mutable { if (auto self = w.lock()) return self->OnRead(std::move(wd), f.get()); - return make_ready_future(absl::optional{}); + return make_ready_future(std::optional{}); }); } - future> OnRead(future watchdog, - absl::optional response) { + future> OnRead(future watchdog, + std::optional response) { watchdog.cancel(); return watchdog.then( [w = WeakFromThis(), r = std::move(response)](auto f) mutable { auto expired = f.get(); - if (expired) return absl::optional{}; + if (expired) return std::optional{}; return std::move(r); }); } diff --git a/google/cloud/internal/async_read_write_stream_timeout_test.cc b/google/cloud/internal/async_read_write_stream_timeout_test.cc index 37c966412edee..386b5d1b4f83b 100644 --- a/google/cloud/internal/async_read_write_stream_timeout_test.cc +++ b/google/cloud/internal/async_read_write_stream_timeout_test.cc @@ -131,7 +131,7 @@ TEST(AsyncStreamingReadWriteRpcTimeout, ReadSuccess) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([&] { return sequencer.PushBack("Read").then( - [](auto) { return absl::make_optional(std::string("42")); }); + [](auto) { return std::make_optional(std::string("42")); }); }); EXPECT_CALL(*mock, Cancel).Times(0); @@ -161,7 +161,7 @@ TEST(AsyncStreamingReadWriteRpcTimeout, ReadTimeout) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([&] { return sequencer.PushBack("Read").then( - [](auto) { return absl::make_optional(std::string("42")); }); + [](auto) { return std::make_optional(std::string("42")); }); }); EXPECT_CALL(*mock, Cancel).Times(1); @@ -183,7 +183,7 @@ TEST(AsyncStreamingReadWriteRpcTimeout, ReadTimeout) { ASSERT_THAT(read.second, "Read"); timer.first.set_value(true); read.first.set_value(true); - EXPECT_EQ(result.get(), absl::optional{}); + EXPECT_EQ(result.get(), std::optional{}); } TEST(AsyncStreamingReadWriteRpcTimeout, WriteSuccess) { diff --git a/google/cloud/internal/async_read_write_stream_tracing.h b/google/cloud/internal/async_read_write_stream_tracing.h index 707daa4962fc5..ce9a8c1dbf5bc 100644 --- a/google/cloud/internal/async_read_write_stream_tracing.h +++ b/google/cloud/internal/async_read_write_stream_tracing.h @@ -58,9 +58,9 @@ class AsyncStreamingReadWriteRpcTracing }); } - future> Read() override { + future> Read() override { if (read_count_ == 0) span_->AddEvent("gl-cpp.first-read"); - return impl_->Read().then([this](future> f) { + return impl_->Read().then([this](future> f) { auto r = f.get(); if (r.has_value()) { span_->AddEvent("message", {{"message.type", "RECEIVED"}, diff --git a/google/cloud/internal/async_read_write_stream_tracing_test.cc b/google/cloud/internal/async_read_write_stream_tracing_test.cc index 3ea59eab6990d..0b4911d61a6de 100644 --- a/google/cloud/internal/async_read_write_stream_tracing_test.cc +++ b/google/cloud/internal/async_read_write_stream_tracing_test.cc @@ -114,11 +114,11 @@ TEST(AsyncStreamingReadWriteRpcTracing, Read) { auto span = MakeSpan("span"); auto mock = std::make_unique(); EXPECT_CALL(*mock, Read) - .WillOnce([] { return make_ready_future(absl::make_optional(100)); }) - .WillOnce([] { return make_ready_future(absl::make_optional(200)); }) - .WillOnce([] { return make_ready_future(absl::make_optional(300)); }) + .WillOnce([] { return make_ready_future(std::make_optional(100)); }) + .WillOnce([] { return make_ready_future(std::make_optional(200)); }) + .WillOnce([] { return make_ready_future(std::make_optional(300)); }) .WillOnce( - [] { return make_ready_future>(absl::nullopt); }); + [] { return make_ready_future>(std::nullopt); }); EXPECT_CALL(*mock, Finish) .WillOnce(Return(make_ready_future(internal::AbortedError("fail")))); @@ -207,7 +207,7 @@ TEST(AsyncStreamingReadWriteRpcTracing, SeparateCountersForReadAndWrite) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Write).WillOnce(Return(make_ready_future(true))); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::make_optional(100)); + return make_ready_future(std::make_optional(100)); }); EXPECT_CALL(*mock, Finish) .WillOnce(Return(make_ready_future(internal::AbortedError("fail")))); diff --git a/google/cloud/internal/async_streaming_read_rpc.h b/google/cloud/internal/async_streaming_read_rpc.h index 357f36766d078..49ba65456f7cf 100644 --- a/google/cloud/internal/async_streaming_read_rpc.h +++ b/google/cloud/internal/async_streaming_read_rpc.h @@ -19,8 +19,8 @@ #include "google/cloud/rpc_metadata.h" #include "google/cloud/status.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include +#include namespace google { namespace cloud { @@ -75,7 +75,7 @@ class AsyncStreamingReadRpc { * library should then call `Finish()` to find out if the streaming RPC * was successful or completed with an error. */ - virtual future> Read() = 0; + virtual future> Read() = 0; /** * Return the final status of the streaming RPC. diff --git a/google/cloud/internal/async_streaming_read_rpc_auth.h b/google/cloud/internal/async_streaming_read_rpc_auth.h index da865cd5ec745..b0a6144e104c5 100644 --- a/google/cloud/internal/async_streaming_read_rpc_auth.h +++ b/google/cloud/internal/async_streaming_read_rpc_auth.h @@ -56,7 +56,7 @@ class AsyncStreamingReadRpcAuth : public AsyncStreamingReadRpc { }); } - future> Read() override { + future> Read() override { std::lock_guard g{state_->mu}; return state_->stream->Read(); } diff --git a/google/cloud/internal/async_streaming_read_rpc_auth_test.cc b/google/cloud/internal/async_streaming_read_rpc_auth_test.cc index d924820f2f417..932639e790235 100644 --- a/google/cloud/internal/async_streaming_read_rpc_auth_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_auth_test.cc @@ -49,7 +49,7 @@ TEST(AsyncStreamReadWriteAuth, Start) { auto mock = std::make_unique>(); EXPECT_CALL(*mock, Start).WillOnce([] { return make_ready_future(true); }); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::make_optional(FakeResponse{"k0", "v0"})); + return make_ready_future(std::make_optional(FakeResponse{"k0", "v0"})); }); EXPECT_CALL(*mock, Finish).WillOnce([] { return make_ready_future(Status{}); @@ -122,11 +122,11 @@ TEST(AsyncStreamReadWriteAuth, CancelAfterStart) { ::testing::InSequence sequence; EXPECT_CALL(*mock, Start).WillOnce([] { return make_ready_future(true); }); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::make_optional(FakeResponse{"k0", "v0"})); + return make_ready_future(std::make_optional(FakeResponse{"k0", "v0"})); }); EXPECT_CALL(*mock, Cancel).Times(1); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::optional{}); + return make_ready_future(std::optional{}); }); EXPECT_CALL(*mock, Finish).WillOnce([] { return make_ready_future(Status{}); diff --git a/google/cloud/internal/async_streaming_read_rpc_impl.h b/google/cloud/internal/async_streaming_read_rpc_impl.h index 2e8adce4ebbab..441c1f3cc70f9 100644 --- a/google/cloud/internal/async_streaming_read_rpc_impl.h +++ b/google/cloud/internal/async_streaming_read_rpc_impl.h @@ -26,9 +26,9 @@ #include "google/cloud/options.h" #include "google/cloud/version.h" #include "absl/functional/function_ref.h" -#include "absl/types/optional.h" #include #include +#include #include namespace google { @@ -76,7 +76,7 @@ class AsyncStreamingReadRpcImpl : public AsyncStreamingReadRpc { return op->p.get_future(); } - future> Read() override { + future> Read() override { struct OnRead : public AsyncGrpcOperation { explicit OnRead(ImmutableOptions o) : call_context(std::move(o)) {} @@ -91,7 +91,7 @@ class AsyncStreamingReadRpcImpl : public AsyncStreamingReadRpc { } void Cancel() override {} - promise> p; + promise> p; Response response; CallContext call_context; }; @@ -179,8 +179,8 @@ class AsyncStreamingReadRpcError : public AsyncStreamingReadRpc { void Cancel() override {} future Start() override { return make_ready_future(false); } - future> Read() override { - return make_ready_future>(absl::nullopt); + future> Read() override { + return make_ready_future>(std::nullopt); } future Finish() override { return make_ready_future(status_); } RpcMetadata GetRequestMetadata() const override { return {}; } diff --git a/google/cloud/internal/async_streaming_read_rpc_impl_test.cc b/google/cloud/internal/async_streaming_read_rpc_impl_test.cc index e8a1fbfaede47..f991cbcddf8ed 100644 --- a/google/cloud/internal/async_streaming_read_rpc_impl_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_impl_test.cc @@ -105,7 +105,7 @@ TEST(AsyncStreamingReadRpcTest, Basic) { return Options{}.set(value); }; auto check_read_span = [](std::string const& expected) { - return [expected](future> f) { + return [expected](future> f) { EXPECT_EQ(CurrentOptions().get(), expected); return f.get(); }; diff --git a/google/cloud/internal/async_streaming_read_rpc_logging.h b/google/cloud/internal/async_streaming_read_rpc_logging.h index 112f68dc9d2e0..0f780430ce48e 100644 --- a/google/cloud/internal/async_streaming_read_rpc_logging.h +++ b/google/cloud/internal/async_streaming_read_rpc_logging.h @@ -52,12 +52,12 @@ class AsyncStreamingReadRpcLogging : public AsyncStreamingReadRpc { }); } - future> Read() override { + future> Read() override { auto prefix = std::string(__func__) + "(" + request_id_ + ")"; auto const& opt = tracing_options_; GCP_LOG(DEBUG) << prefix << " <<"; return child_->Read().then( - [prefix, opt](future> f) { + [prefix, opt](future> f) { auto r = f.get(); if (r.has_value()) { GCP_LOG(DEBUG) << prefix << " >> " << DebugString(*r, opt); diff --git a/google/cloud/internal/async_streaming_read_rpc_logging_test.cc b/google/cloud/internal/async_streaming_read_rpc_logging_test.cc index 55cf6fc41ca98..e7a10526a8536 100644 --- a/google/cloud/internal/async_streaming_read_rpc_logging_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_logging_test.cc @@ -64,7 +64,7 @@ TEST(StreamingReadRpcLoggingTest, ReadWithValue) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::make_optional(google::protobuf::Duration{})); + return make_ready_future(std::make_optional(google::protobuf::Duration{})); }); TestedStream stream(std::move(mock), TracingOptions{}, "test-id"); EXPECT_TRUE(stream.Read().get().has_value()); @@ -78,7 +78,7 @@ TEST(StreamingReadRpcLoggingTest, ReadWithoutValue) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([] { - return make_ready_future(absl::optional{}); + return make_ready_future(std::optional{}); }); TestedStream stream(std::move(mock), TracingOptions{}, "test-id"); ASSERT_FALSE(stream.Read().get().has_value()); diff --git a/google/cloud/internal/async_streaming_read_rpc_timeout.h b/google/cloud/internal/async_streaming_read_rpc_timeout.h index f0c7a54d08d51..f9bf5814c8653 100644 --- a/google/cloud/internal/async_streaming_read_rpc_timeout.h +++ b/google/cloud/internal/async_streaming_read_rpc_timeout.h @@ -62,7 +62,7 @@ class AsyncStreamingReadRpcTimeout : public AsyncStreamingReadRpc { future Start() override { return state_->Start(); } - future> Read() override { return state_->Read(); } + future> Read() override { return state_->Read(); } future Finish() override { return state_->child->Finish(); } @@ -104,23 +104,23 @@ class AsyncStreamingReadRpcTimeout : public AsyncStreamingReadRpc { }); } - future> Read() { + future> Read() { auto watchdog = CreateWatchdog(per_read_timeout); return child->Read().then( [watchdog = std::move(watchdog), w = WeakFromThis()](auto f) mutable { if (auto self = w.lock()) return self->OnRead(std::move(watchdog), f.get()); - return make_ready_future(absl::optional()); + return make_ready_future(std::optional()); }); } - future> OnRead(future watchdog, - absl::optional read) { + future> OnRead(future watchdog, + std::optional read) { watchdog.cancel(); return watchdog.then( [w = WeakFromThis(), read = std::move(read)](auto f) mutable { auto expired = f.get(); - if (expired) return absl::optional(); + if (expired) return std::optional(); return std::move(read); }); } diff --git a/google/cloud/internal/async_streaming_read_rpc_timeout_test.cc b/google/cloud/internal/async_streaming_read_rpc_timeout_test.cc index 0f55145d90ff0..addce70791027 100644 --- a/google/cloud/internal/async_streaming_read_rpc_timeout_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_timeout_test.cc @@ -124,8 +124,8 @@ TEST(AsyncStreamingReadRpcTimeout, ReadSuccess) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([&] { return sequencer.PushBack("Read").then([](auto f) { - if (!f.get()) return absl::optional(); - return absl::make_optional(42); + if (!f.get()) return std::optional(); + return std::make_optional(42); }); }); EXPECT_CALL(*mock, Cancel).Times(0); @@ -155,8 +155,8 @@ TEST(AsyncStreamingReadRpcTimeout, ReadTimeout) { auto mock = std::make_unique(); EXPECT_CALL(*mock, Read).WillOnce([&] { return sequencer.PushBack("Read").then([](auto f) { - if (!f.get()) return absl::optional(); - return absl::make_optional(42); + if (!f.get()) return std::optional(); + return std::make_optional(42); }); }); EXPECT_CALL(*mock, Cancel).Times(1); diff --git a/google/cloud/internal/async_streaming_read_rpc_tracing.h b/google/cloud/internal/async_streaming_read_rpc_tracing.h index 2099531b2754d..ccb508abfd1f3 100644 --- a/google/cloud/internal/async_streaming_read_rpc_tracing.h +++ b/google/cloud/internal/async_streaming_read_rpc_tracing.h @@ -57,9 +57,9 @@ class AsyncStreamingReadRpcTracing : public AsyncStreamingReadRpc { }); } - future> Read() override { + future> Read() override { if (read_count_ == 0) span_->AddEvent("gl-cpp.first-read"); - return impl_->Read().then([this](future> f) { + return impl_->Read().then([this](future> f) { auto r = f.get(); if (r.has_value()) { span_->AddEvent("message", {{"message.type", "RECEIVED"}, diff --git a/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc b/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc index 52113a5ccb225..2b78be319bd78 100644 --- a/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc @@ -110,11 +110,11 @@ TEST(AsyncStreamingReadRpcTracing, Read) { auto span = MakeSpan("span"); auto mock = std::make_unique(); EXPECT_CALL(*mock, Read) - .WillOnce([] { return make_ready_future(absl::make_optional(100)); }) - .WillOnce([] { return make_ready_future(absl::make_optional(200)); }) - .WillOnce([] { return make_ready_future(absl::make_optional(300)); }) + .WillOnce([] { return make_ready_future(std::make_optional(100)); }) + .WillOnce([] { return make_ready_future(std::make_optional(200)); }) + .WillOnce([] { return make_ready_future(std::make_optional(300)); }) .WillOnce( - [] { return make_ready_future>(absl::nullopt); }); + [] { return make_ready_future>(std::nullopt); }); EXPECT_CALL(*mock, Finish) .WillOnce(Return(make_ready_future(internal::AbortedError("fail")))); diff --git a/google/cloud/internal/async_streaming_write_rpc_impl.h b/google/cloud/internal/async_streaming_write_rpc_impl.h index 4b73e65a0b0c7..8af85ad53beb5 100644 --- a/google/cloud/internal/async_streaming_write_rpc_impl.h +++ b/google/cloud/internal/async_streaming_write_rpc_impl.h @@ -24,9 +24,9 @@ #include "google/cloud/internal/grpc_request_metadata.h" #include "google/cloud/version.h" #include "absl/functional/function_ref.h" -#include "absl/types/optional.h" #include #include +#include #include namespace google { diff --git a/google/cloud/internal/backoff_policy.h b/google/cloud/internal/backoff_policy.h index 841a6012cb119..d3f2156fd74ca 100644 --- a/google/cloud/internal/backoff_policy.h +++ b/google/cloud/internal/backoff_policy.h @@ -18,9 +18,9 @@ #include "google/cloud/internal/random.h" #include "google/cloud/internal/throw_delegate.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include +#include namespace google { namespace cloud { @@ -208,7 +208,7 @@ class ExponentialBackoffPolicy : public BackoffPolicy { } // Do not copy the PRNG, we get two benefits: - // - This works around a bug triggered by MSVC + `absl::optional` (we do not + // - This works around a bug triggered by MSVC + `std::optional` (we do not // know specifically which one is at fault) // - We want uncorrelated data streams for each copy anyway. ExponentialBackoffPolicy(ExponentialBackoffPolicy const& rhs) noexcept @@ -232,7 +232,7 @@ class ExponentialBackoffPolicy : public BackoffPolicy { double scaling_upper_bound_; DoubleMicroseconds current_delay_start_; DoubleMicroseconds current_delay_end_; - absl::optional generator_; + std::optional generator_; }; } // namespace internal diff --git a/google/cloud/internal/credentials_impl.cc b/google/cloud/internal/credentials_impl.cc index e8266b0a81efb..4014539d7d8f8 100644 --- a/google/cloud/internal/credentials_impl.cc +++ b/google/cloud/internal/credentials_impl.cc @@ -95,8 +95,8 @@ std::vector const& ImpersonateServiceAccountConfig::delegates() } ServiceAccountConfig::ServiceAccountConfig( - absl::optional json_object, - absl::optional file_path, Options opts) + std::optional json_object, + std::optional file_path, Options opts) : json_object_(std::move(json_object)), file_path_(std::move(file_path)), options_(PopulateAuthOptions(std::move(opts))) {} diff --git a/google/cloud/internal/curl_handle_factory.h b/google/cloud/internal/curl_handle_factory.h index d6b49bebb821f..310489d1fafdd 100644 --- a/google/cloud/internal/curl_handle_factory.h +++ b/google/cloud/internal/curl_handle_factory.h @@ -20,9 +20,9 @@ #include "google/cloud/rest_options.h" #include "google/cloud/version.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include #include +#include #include #include @@ -55,8 +55,8 @@ class CurlHandleFactory { // For testing and debug only, we do not need anything more elaborate as this // class is in `internal::`. - virtual absl::optional cainfo() const = 0; - virtual absl::optional capath() const = 0; + virtual std::optional cainfo() const = 0; + virtual std::optional capath() const = 0; virtual std::vector const& ca_certs() const = 0; virtual experimental::SslCtxCallback ssl_ctx_callback() const = 0; @@ -93,8 +93,8 @@ class DefaultCurlHandleFactory : public CurlHandleFactory { return last_client_ip_address_; } - absl::optional cainfo() const override { return cainfo_; } - absl::optional capath() const override { return capath_; } + std::optional cainfo() const override { return cainfo_; } + std::optional capath() const override { return capath_; } std::vector const& ca_certs() const override { return ca_certs_; } @@ -107,8 +107,8 @@ class DefaultCurlHandleFactory : public CurlHandleFactory { mutable std::mutex mu_; std::string last_client_ip_address_; - absl::optional cainfo_; - absl::optional capath_; + std::optional cainfo_; + std::optional capath_; std::vector ca_certs_; experimental::SslCtxCallback ssl_ctx_callback_; }; @@ -148,8 +148,8 @@ class PooledCurlHandleFactory : public CurlHandleFactory { return multi_handles_.size(); } - absl::optional cainfo() const override { return cainfo_; } - absl::optional capath() const override { return capath_; } + std::optional cainfo() const override { return cainfo_; } + std::optional capath() const override { return capath_; } std::vector const& ca_certs() const override { return ca_certs_; } @@ -162,8 +162,8 @@ class PooledCurlHandleFactory : public CurlHandleFactory { // These are constant after initialization and thus need no locking. std::size_t const maximum_size_; - absl::optional cainfo_; - absl::optional capath_; + std::optional cainfo_; + std::optional capath_; std::vector ca_certs_; experimental::SslCtxCallback ssl_ctx_callback_; diff --git a/google/cloud/internal/curl_impl.cc b/google/cloud/internal/curl_impl.cc index 9d897bfe59909..c494e795441a8 100644 --- a/google/cloud/internal/curl_impl.cc +++ b/google/cloud/internal/curl_impl.cc @@ -870,31 +870,31 @@ void CurlImpl::OnTransferDone() { factory_->CleanupMultiHandle(std::move(multi_), HandleDisposition::kKeep); } -absl::optional CurlOptProxy(Options const& options) { - if (!options.has()) return absl::nullopt; +std::optional CurlOptProxy(Options const& options) { + if (!options.has()) return std::nullopt; auto const& cfg = options.get(); - if (cfg.hostname().empty()) return absl::nullopt; + if (cfg.hostname().empty()) return std::nullopt; if (cfg.port().empty()) { return absl::StrCat(cfg.scheme(), "://", cfg.hostname()); } return absl::StrCat(cfg.scheme(), "://", cfg.hostname(), ":", cfg.port()); } -absl::optional CurlOptProxyUsername(Options const& options) { +std::optional CurlOptProxyUsername(Options const& options) { auto const& cfg = options.get(); - if (cfg.username().empty()) return absl::nullopt; + if (cfg.username().empty()) return std::nullopt; return cfg.username(); } -absl::optional CurlOptProxyPassword(Options const& options) { +std::optional CurlOptProxyPassword(Options const& options) { auto const& cfg = options.get(); - if (cfg.password().empty()) return absl::nullopt; + if (cfg.password().empty()) return std::nullopt; return cfg.password(); } -absl::optional CurlOptInterface(Options const& options) { +std::optional CurlOptInterface(Options const& options) { auto const& cfg = options.get(); - if (cfg.empty()) return absl::nullopt; + if (cfg.empty()) return std::nullopt; return cfg; } diff --git a/google/cloud/internal/curl_impl.h b/google/cloud/internal/curl_impl.h index c71078aeeacd4..dbb8285d8ffba 100644 --- a/google/cloud/internal/curl_impl.h +++ b/google/cloud/internal/curl_impl.h @@ -27,13 +27,13 @@ #include "google/cloud/ssl_certificate.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include "absl/types/span.h" #include #include #include #include #include +#include #include #include @@ -149,13 +149,13 @@ class CurlImpl { std::chrono::seconds download_stall_timeout_; std::uint32_t download_stall_minimum_rate_; - absl::optional proxy_; - absl::optional proxy_username_; - absl::optional proxy_password_; + std::optional proxy_; + std::optional proxy_username_; + std::optional proxy_password_; - absl::optional client_ssl_cert_ = absl::nullopt; + std::optional client_ssl_cert_ = std::nullopt; - absl::optional interface_; + std::optional interface_; CurlReceivedHeaders received_headers_; std::string url_; @@ -198,16 +198,16 @@ class CurlImpl { }; /// Compute the CURLOPT_PROXY setting from @p options. -absl::optional CurlOptProxy(Options const& options); +std::optional CurlOptProxy(Options const& options); /// Compute the CURLOPT_PROXYUSERNAME setting from @p options. -absl::optional CurlOptProxyUsername(Options const& options); +std::optional CurlOptProxyUsername(Options const& options); /// Compute the CURLOPT_PROXYPASSWORD setting from @p options. -absl::optional CurlOptProxyPassword(Options const& options); +std::optional CurlOptProxyPassword(Options const& options); /// Compute the CURLOPT_INTERFACE setting from @p options. -absl::optional CurlOptInterface(Options const& options); +std::optional CurlOptInterface(Options const& options); GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal diff --git a/google/cloud/internal/curl_impl_test.cc b/google/cloud/internal/curl_impl_test.cc index d2f97d00d57eb..689a72bbef58c 100644 --- a/google/cloud/internal/curl_impl_test.cc +++ b/google/cloud/internal/curl_impl_test.cc @@ -148,44 +148,44 @@ TEST_F(CurlImplTest, SetUrlPathContainsHttp) { } TEST_F(CurlImplTest, CurlOptProxy) { - EXPECT_EQ(CurlOptProxy(Options{}), absl::nullopt); + EXPECT_EQ(CurlOptProxy(Options{}), std::nullopt); EXPECT_EQ(CurlOptProxy(Options{}.set( ProxyConfig().set_hostname("hostname"))), - absl::make_optional(std::string("https://hostname"))); + std::make_optional(std::string("https://hostname"))); EXPECT_EQ( CurlOptProxy(Options{}.set(ProxyConfig() .set_hostname("hostname") .set_port("1080") .set_scheme("http"))), - absl::make_optional(std::string("htt" /*silence*/ "p://hostname:1080"))); + std::make_optional(std::string("htt" /*silence*/ "p://hostname:1080"))); } TEST_F(CurlImplTest, CurlOptProxyUsername) { - EXPECT_EQ(CurlOptProxyUsername(Options{}), absl::nullopt); + EXPECT_EQ(CurlOptProxyUsername(Options{}), std::nullopt); EXPECT_EQ(CurlOptProxyUsername(Options{}.set( ProxyConfig().set_hostname("hostname"))), - absl::nullopt); + std::nullopt); EXPECT_EQ( CurlOptProxyUsername(Options{}.set( ProxyConfig().set_hostname("hostname").set_username("username"))), - absl::make_optional(std::string("username"))); + std::make_optional(std::string("username"))); } TEST_F(CurlImplTest, CurlOptProxyPassword) { - EXPECT_EQ(CurlOptProxyPassword(Options{}), absl::nullopt); + EXPECT_EQ(CurlOptProxyPassword(Options{}), std::nullopt); EXPECT_EQ(CurlOptProxyPassword(Options{}.set( ProxyConfig().set_hostname("hostname"))), - absl::nullopt); + std::nullopt); EXPECT_EQ( CurlOptProxyPassword(Options{}.set( ProxyConfig().set_hostname("hostname").set_password("password"))), - absl::make_optional(std::string("password"))); + std::make_optional(std::string("password"))); } TEST_F(CurlImplTest, CurlOptInterface) { - EXPECT_EQ(CurlOptInterface(Options{}), absl::nullopt); + EXPECT_EQ(CurlOptInterface(Options{}), std::nullopt); EXPECT_EQ(CurlOptInterface(Options{}.set("interface")), - absl::make_optional(std::string("interface"))); + std::make_optional(std::string("interface"))); } TEST_F(CurlImplTest, MergeAndWriteHeadersEmpty) { diff --git a/google/cloud/internal/curl_rest_client_integration_test.cc b/google/cloud/internal/curl_rest_client_integration_test.cc index fa883ccd1d555..f4fc2ff22b99f 100644 --- a/google/cloud/internal/curl_rest_client_integration_test.cc +++ b/google/cloud/internal/curl_rest_client_integration_test.cc @@ -79,7 +79,7 @@ class RestClientIntegrationTest : public ::testing::Test { static void VerifyJsonPayloadResponse( std::string const& method, std::string const& json_payload, StatusOr> response_status, - absl::optional const& request_content_length) { + std::optional const& request_content_length) { ASSERT_STATUS_OK(response_status); auto response = std::move(response_status.value()); EXPECT_THAT(response->StatusCode(), Eq(HttpStatusCode::kOk)); diff --git a/google/cloud/internal/debug_string.cc b/google/cloud/internal/debug_string.cc index 13c0349e5a0da..4cf28c3fcf967 100644 --- a/google/cloud/internal/debug_string.cc +++ b/google/cloud/internal/debug_string.cc @@ -48,7 +48,7 @@ DebugFormatter& DebugFormatter::Field( DebugFormatter& DebugFormatter::Field( absl::string_view field_name, - absl::optional value) { + std::optional value) { return value ? Field(field_name, *value) : *this; } diff --git a/google/cloud/internal/debug_string.h b/google/cloud/internal/debug_string.h index 3c9f60d0de2b7..7611ea1c01ca7 100644 --- a/google/cloud/internal/debug_string.h +++ b/google/cloud/internal/debug_string.h @@ -20,9 +20,9 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "absl/types/optional.h" #include #include +#include #include #include @@ -55,7 +55,7 @@ class DebugFormatter { std::chrono::system_clock::time_point value); DebugFormatter& Field( absl::string_view field_name, - absl::optional value); + std::optional value); DebugFormatter& Field(absl::string_view field_name, std::vector const& value); DebugFormatter& Field(absl::string_view field_name, @@ -83,7 +83,7 @@ class DebugFormatter { template DebugFormatter& Field(absl::string_view field_name, - absl::optional const& value) { + std::optional const& value) { if (value) { absl::StrAppend(&str_, value->DebugString(field_name, options_, indent_)); } diff --git a/google/cloud/internal/debug_string_test.cc b/google/cloud/internal/debug_string_test.cc index 63c4c344f4d41..86822aa600147 100644 --- a/google/cloud/internal/debug_string_test.cc +++ b/google/cloud/internal/debug_string_test.cc @@ -93,7 +93,7 @@ TEST(DebugFormatter, Truncated) { } TEST(DebugFormatter, TimePoint) { - absl::optional tp = + std::optional tp = std::chrono::system_clock::from_time_t(1681165293) + std::chrono::microseconds(123456); EXPECT_EQ(DebugFormatter("message_name", TracingOptions{}) @@ -112,7 +112,7 @@ TEST(DebugFormatter, TimePoint) { R"( "2023-04-10T22:21:33.123456Z")" R"( })" R"( })"); - tp = absl::nullopt; + tp = std::nullopt; EXPECT_EQ(DebugFormatter("message_name", TracingOptions{}) .Field("field1", tp) .Build(), @@ -207,7 +207,7 @@ TEST(DebugFormatter, Multimap) { } TEST(DebugFormatter, Optional) { - absl::optional m = SubMessage{3.14159}; + std::optional m = SubMessage{3.14159}; EXPECT_EQ(DebugFormatter("message_name", TracingOptions{}) .Field("field1", m) .Build(), @@ -216,7 +216,7 @@ TEST(DebugFormatter, Optional) { R"( sub_field: 3.14159)" R"( })" R"( })"); - m = absl::nullopt; + m = std::nullopt; EXPECT_EQ(DebugFormatter("message_name", TracingOptions{}) .Field("field1", m) .Build(), diff --git a/google/cloud/internal/external_account_token_source_aws_test.cc b/google/cloud/internal/external_account_token_source_aws_test.cc index ba0c5252783ba..e3fe1b85820bd 100644 --- a/google/cloud/internal/external_account_token_source_aws_test.cc +++ b/google/cloud/internal/external_account_token_source_aws_test.cc @@ -156,14 +156,14 @@ TEST(ExternalAccountTokenSource, SourceImdsv2Failure) { // Return an error in fetching the imdsv2 token. In any implementation the // imdsv2 query *must* happen if it is needed to fetch the region and secrets. // Unset the environment variables to set that behavior. - auto const region = ScopedEnvironment("AWS_REGION", absl::nullopt); + auto const region = ScopedEnvironment("AWS_REGION", std::nullopt); auto const default_region = - ScopedEnvironment("AWS_DEFAULT_REGION", absl::nullopt); + ScopedEnvironment("AWS_DEFAULT_REGION", std::nullopt); auto const access_key_id = - ScopedEnvironment("AWS_ACCESS_KEY_ID", absl::nullopt); + ScopedEnvironment("AWS_ACCESS_KEY_ID", std::nullopt); auto const secret_access_key = - ScopedEnvironment("AWS_SECRET_ACCESS_KEY", absl::nullopt); - auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", absl::nullopt); + ScopedEnvironment("AWS_SECRET_ACCESS_KEY", std::nullopt); + auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", std::nullopt); auto const credentials_source = nlohmann::json{ {"environment_id", "aws1"}, {"region_url", kTestRegionUrl}, @@ -196,9 +196,9 @@ TEST(ExternalAccountTokenSource, SourceRegionFailure) { // Do not use imdsv2, and force a metadata query to get the region. Use // environment variables for the secrets, in case the implementation order // changes. - auto const region = ScopedEnvironment("AWS_REGION", absl::nullopt); + auto const region = ScopedEnvironment("AWS_REGION", std::nullopt); auto const default_region = - ScopedEnvironment("AWS_DEFAULT_REGION", absl::nullopt); + ScopedEnvironment("AWS_DEFAULT_REGION", std::nullopt); auto const access_key_id = ScopedEnvironment("AWS_ACCESS_KEY_ID", "test-access-key-id"); auto const secret_access_key = @@ -239,10 +239,10 @@ TEST(ExternalAccountTokenSource, SourceSecretsFailure) { // the region set, so this test works regardless of the query order. auto const region = ScopedEnvironment("AWS_REGION", "us-central1"); auto const access_key_id = - ScopedEnvironment("AWS_ACCESS_KEY_ID", absl::nullopt); + ScopedEnvironment("AWS_ACCESS_KEY_ID", std::nullopt); auto const secret_access_key = - ScopedEnvironment("AWS_SECRET_ACCESS_KEY", absl::nullopt); - auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", absl::nullopt); + ScopedEnvironment("AWS_SECRET_ACCESS_KEY", std::nullopt); + auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", std::nullopt); auto const credentials_source = nlohmann::json{ {"environment_id", "aws1"}, {"region_url", kTestRegionUrl}, @@ -618,7 +618,7 @@ TEST(ExternalAccountTokenSource, FetchRegionFromEnvRegion) { TEST(ExternalAccountTokenSource, FetchRegionFromEnvDefaultRegion) { auto const info = MakeTestInfoImdsV1(); - auto const region = ScopedEnvironment("AWS_REGION", absl::nullopt); + auto const region = ScopedEnvironment("AWS_REGION", std::nullopt); auto const default_region = ScopedEnvironment("AWS_DEFAULT_REGION", "default-region"); @@ -634,9 +634,9 @@ TEST(ExternalAccountTokenSource, FetchRegionFromEnvDefaultRegion) { TEST(ExternalAccountTokenSource, FetchRegionFromUrlV1) { auto const info = MakeTestInfoImdsV1(); - auto const region = ScopedEnvironment("AWS_REGION", absl::nullopt); + auto const region = ScopedEnvironment("AWS_REGION", std::nullopt); auto const default_region = - ScopedEnvironment("AWS_DEFAULT_REGION", absl::nullopt); + ScopedEnvironment("AWS_DEFAULT_REGION", std::nullopt); MockClientFactory client_factory; EXPECT_CALL(client_factory, Call(make_expected_options())) @@ -657,9 +657,9 @@ TEST(ExternalAccountTokenSource, FetchRegionFromUrlV1) { TEST(ExternalAccountTokenSource, FetchRegionFromUrlV2) { auto const info = MakeTestInfoImdsV2(); - auto const region = ScopedEnvironment("AWS_REGION", absl::nullopt); + auto const region = ScopedEnvironment("AWS_REGION", std::nullopt); auto const default_region = - ScopedEnvironment("AWS_DEFAULT_REGION", absl::nullopt); + ScopedEnvironment("AWS_DEFAULT_REGION", std::nullopt); MockClientFactory client_factory; EXPECT_CALL(client_factory, Call(make_expected_options())) @@ -685,9 +685,9 @@ TEST(ExternalAccountTokenSource, FetchRegionFromUrlV2) { TEST(ExternalAccountTokenSource, FetchRegionFromUrlEmpty) { auto const info = MakeTestInfoImdsV1(); - auto const region = ScopedEnvironment("AWS_REGION", absl::nullopt); + auto const region = ScopedEnvironment("AWS_REGION", std::nullopt); auto const default_region = - ScopedEnvironment("AWS_DEFAULT_REGION", absl::nullopt); + ScopedEnvironment("AWS_DEFAULT_REGION", std::nullopt); MockClientFactory client_factory; EXPECT_CALL(client_factory, Call(make_expected_options())) @@ -736,7 +736,7 @@ TEST(ExternalAccountTokenSource, FetchSecretsFromEnvNoSessionToken) { ScopedEnvironment("AWS_ACCESS_KEY_ID", "test-access-key-id"); auto const secret_access_key = ScopedEnvironment("AWS_SECRET_ACCESS_KEY", "test-secret-access-key"); - auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", absl::nullopt); + auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", std::nullopt); MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).Times(0); @@ -753,10 +753,10 @@ TEST(ExternalAccountTokenSource, FetchSecretsFromEnvNoSessionToken) { TEST(ExternalAccountTokenSource, FetchSecretsFromUrlV1) { auto const info = MakeTestInfoImdsV1(); auto const access_key_id = - ScopedEnvironment("AWS_ACCESS_KEY_ID", absl::nullopt); + ScopedEnvironment("AWS_ACCESS_KEY_ID", std::nullopt); auto const secret_access_key = - ScopedEnvironment("AWS_SECRET_ACCESS_KEY", absl::nullopt); - auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", absl::nullopt); + ScopedEnvironment("AWS_SECRET_ACCESS_KEY", std::nullopt); + auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", std::nullopt); auto make_client = [](std::string const& url, std::string const& contents) { auto mock = std::make_unique(); @@ -792,10 +792,10 @@ TEST(ExternalAccountTokenSource, FetchSecretsFromUrlV1) { TEST(ExternalAccountTokenSource, FetchSecretsFromUrlV2) { auto const info = MakeTestInfoImdsV2(); auto const access_key_id = - ScopedEnvironment("AWS_ACCESS_KEY_ID", absl::nullopt); + ScopedEnvironment("AWS_ACCESS_KEY_ID", std::nullopt); auto const secret_access_key = - ScopedEnvironment("AWS_SECRET_ACCESS_KEY", absl::nullopt); - auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", absl::nullopt); + ScopedEnvironment("AWS_SECRET_ACCESS_KEY", std::nullopt); + auto const token = ScopedEnvironment("AWS_SESSION_TOKEN", std::nullopt); auto make_client = [](std::string const& url, std::string const& contents) { auto mock = std::make_unique(); diff --git a/google/cloud/internal/getenv.cc b/google/cloud/internal/getenv.cc index 166bf78fe18d1..752e525966831 100644 --- a/google/cloud/internal/getenv.cc +++ b/google/cloud/internal/getenv.cc @@ -27,7 +27,7 @@ namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { -absl::optional GetEnv(char const* variable) { +std::optional GetEnv(char const* variable) { #if defined(_MSC_VER) // With MSVC, std::getenv() is not thread-safe. It returns a pointer that can // be invalidated by _putenv_s(). We must use the thread-safe alternative, @@ -39,7 +39,7 @@ absl::optional GetEnv(char const* variable) { #else char* buffer = std::getenv(variable); #endif // _MSC_VER - if (buffer == nullptr) return absl::nullopt; + if (buffer == nullptr) return std::nullopt; return std::string{buffer}; } diff --git a/google/cloud/internal/getenv.h b/google/cloud/internal/getenv.h index 8a5e0736646ca..eb463e4eba7f1 100644 --- a/google/cloud/internal/getenv.h +++ b/google/cloud/internal/getenv.h @@ -16,7 +16,7 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_GETENV_H #include "google/cloud/version.h" -#include "absl/types/optional.h" +#include #include namespace google { @@ -25,12 +25,12 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { /** - * Return the value of an environment variable, or an unset `absl::optional`. + * Return the value of an environment variable, or an unset `std::optional`. * * On Windows `std::getenv()` is not thread safe. We must write a wrapper to * portably get the value of the environment variables. */ -absl::optional GetEnv(char const* variable); +std::optional GetEnv(char const* variable); } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/log_impl_test.cc b/google/cloud/internal/log_impl_test.cc index 8a83de9bcfcf1..8b0f24410c850 100644 --- a/google/cloud/internal/log_impl_test.cc +++ b/google/cloud/internal/log_impl_test.cc @@ -127,7 +127,7 @@ TEST(PerThreadCircularBufferBackend, Basic) { TEST(DefaultLogBackend, CircularBuffer) { ScopedEnvironment config(kLogConfig, "lastN,5,WARNING"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* buffer = dynamic_cast(be.get()); ASSERT_NE(buffer, nullptr); @@ -140,7 +140,7 @@ TEST(DefaultLogBackend, CircularBuffer) { TEST(DefaultLogBackend, PerThreadCircularBuffer) { ScopedEnvironment config(kLogConfig, "thread-lastN,5,WARNING"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* buffer = dynamic_cast(be.get()); ASSERT_NE(buffer, nullptr); @@ -153,7 +153,7 @@ TEST(DefaultLogBackend, PerThreadCircularBuffer) { TEST(DefaultLogBackend, CLog) { ScopedEnvironment config(kLogConfig, "clog"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); ASSERT_THAT(clog_be, NotNull()); @@ -161,7 +161,7 @@ TEST(DefaultLogBackend, CLog) { } TEST(DefaultLogBackend, BackwardsCompatibilityCLog) { - ScopedEnvironment config(kLogConfig, absl::nullopt); + ScopedEnvironment config(kLogConfig, std::nullopt); ScopedEnvironment clog(kEnableClog, "yes"); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); @@ -170,8 +170,8 @@ TEST(DefaultLogBackend, BackwardsCompatibilityCLog) { } TEST(DefaultLogBackend, BackwardsCompatibilityCLogUnset) { - ScopedEnvironment config(kLogConfig, absl::nullopt); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment config(kLogConfig, std::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); ASSERT_THAT(clog_be, NotNull()); @@ -179,7 +179,7 @@ TEST(DefaultLogBackend, BackwardsCompatibilityCLogUnset) { } TEST(DefaultLogBackend, BackwardsCompatibilityCLogWithSeverity) { - ScopedEnvironment config(kLogConfig, absl::nullopt); + ScopedEnvironment config(kLogConfig, std::nullopt); ScopedEnvironment clog(kEnableClog, "WARNING"); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); @@ -189,7 +189,7 @@ TEST(DefaultLogBackend, BackwardsCompatibilityCLogWithSeverity) { TEST(DefaultLogBackend, UnknownType) { ScopedEnvironment config(kLogConfig, "invalid"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); ASSERT_THAT(clog_be, NotNull()); @@ -198,7 +198,7 @@ TEST(DefaultLogBackend, UnknownType) { TEST(DefaultLogBackend, MissingComponents) { ScopedEnvironment config(kLogConfig, "lastN,1"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); ASSERT_THAT(clog_be, NotNull()); @@ -207,7 +207,7 @@ TEST(DefaultLogBackend, MissingComponents) { TEST(DefaultLogBackend, InvalidSize) { ScopedEnvironment config(kLogConfig, "lastN,-10,WARNING"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); ASSERT_THAT(clog_be, NotNull()); @@ -216,7 +216,7 @@ TEST(DefaultLogBackend, InvalidSize) { TEST(DefaultLogBackend, InvalidSeverity) { ScopedEnvironment config(kLogConfig, "lastN,10,invalid"); - ScopedEnvironment clog(kEnableClog, absl::nullopt); + ScopedEnvironment clog(kEnableClog, std::nullopt); auto be = DefaultLogBackend(); auto const* clog_be = dynamic_cast(be.get()); ASSERT_THAT(clog_be, NotNull()); diff --git a/google/cloud/internal/make_status.h b/google/cloud/internal/make_status.h index 939f289ea6de1..464c21a0afc0e 100644 --- a/google/cloud/internal/make_status.h +++ b/google/cloud/internal/make_status.h @@ -109,7 +109,7 @@ class ErrorInfoBuilder { ErrorInfo Build(StatusCode code) &&; private: - absl::optional reason_; + std::optional reason_; std::unordered_map metadata_; }; diff --git a/google/cloud/internal/noexcept_action.h b/google/cloud/internal/noexcept_action.h index 6b7dfd72a65be..e8351afe90c19 100644 --- a/google/cloud/internal/noexcept_action.h +++ b/google/cloud/internal/noexcept_action.h @@ -17,7 +17,7 @@ #include "google/cloud/version.h" #include "absl/functional/function_ref.h" -#include "absl/types/optional.h" +#include namespace google { namespace cloud { @@ -36,17 +36,17 @@ bool NoExceptAction(absl::FunctionRef action) noexcept; * Execute an action that can throw in a noexcept context. * * Returns the result of the action, if it was successful (i.e. it did not - * throw). Returns absl::nullopt if the action throws. + * throw). Returns std::nullopt if the action throws. */ template #if GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS -absl::optional NoExceptAction(absl::FunctionRef action) noexcept try { +std::optional NoExceptAction(absl::FunctionRef action) noexcept try { return action(); } catch (...) { - return absl::nullopt; + return std::nullopt; } #else -absl::optional NoExceptAction(absl::FunctionRef action) noexcept { +std::optional NoExceptAction(absl::FunctionRef action) noexcept { // If this crashes, it would have crashed anyway. return action(); } diff --git a/google/cloud/internal/noexcept_action_test.cc b/google/cloud/internal/noexcept_action_test.cc index efb8129aa87a4..c7a3c13c4b0b1 100644 --- a/google/cloud/internal/noexcept_action_test.cc +++ b/google/cloud/internal/noexcept_action_test.cc @@ -42,7 +42,7 @@ TEST(NoExceptActionVoid, ActionThatDoesNotThrow) { TEST(NoExceptActionNonVoid, ActionThatThrows) { auto action = []() -> int { ThrowRuntimeError("fail"); }; #if GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS - EXPECT_EQ(NoExceptAction(action), absl::nullopt); + EXPECT_EQ(NoExceptAction(action), std::nullopt); #else EXPECT_DEATH_IF_SUPPORTED(NoExceptAction(action), "fail"); #endif // GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS diff --git a/google/cloud/internal/oauth2_background_credentials.h b/google/cloud/internal/oauth2_background_credentials.h index 37f2c8b69718e..f710208e1a2e5 100644 --- a/google/cloud/internal/oauth2_background_credentials.h +++ b/google/cloud/internal/oauth2_background_credentials.h @@ -21,9 +21,9 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include +#include #include namespace google { @@ -44,7 +44,7 @@ class BackgroundCredentials : public Credentials { : background_(std::move(background)), child_(std::move(child)) {} StatusOr> SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const override { return child_->SignBlob(signing_service_account, string_to_sign); } diff --git a/google/cloud/internal/oauth2_cached_credentials.cc b/google/cloud/internal/oauth2_cached_credentials.cc index 11d81c5fdf18f..874c260934c94 100644 --- a/google/cloud/internal/oauth2_cached_credentials.cc +++ b/google/cloud/internal/oauth2_cached_credentials.cc @@ -54,7 +54,7 @@ StatusOr CachedCredentials::GetToken( } StatusOr> CachedCredentials::SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const { return impl_->SignBlob(signing_service_account, string_to_sign); } diff --git a/google/cloud/internal/oauth2_cached_credentials.h b/google/cloud/internal/oauth2_cached_credentials.h index ee8e18e9eb8ba..ce3d1c3a5d07e 100644 --- a/google/cloud/internal/oauth2_cached_credentials.h +++ b/google/cloud/internal/oauth2_cached_credentials.h @@ -46,7 +46,7 @@ class CachedCredentials : public Credentials { StatusOr GetToken( std::chrono::system_clock::time_point now) override; StatusOr> SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const override; std::string AccountEmail() const override; std::string KeyId() const override; diff --git a/google/cloud/internal/oauth2_cached_credentials_test.cc b/google/cloud/internal/oauth2_cached_credentials_test.cc index 3b23a5a1af7e7..95827cedc66cb 100644 --- a/google/cloud/internal/oauth2_cached_credentials_test.cc +++ b/google/cloud/internal/oauth2_cached_credentials_test.cc @@ -38,7 +38,7 @@ class MockCredentials : public Credentials { MOCK_METHOD(StatusOr, GetToken, (std::chrono::system_clock::time_point), (override)); MOCK_METHOD(StatusOr>, SignBlob, - (absl::optional const&, std::string const&), + (std::optional const&, std::string const&), (const, override)); MOCK_METHOD(std::string, AccountEmail, (), (const, override)); MOCK_METHOD(std::string, KeyId, (), (const, override)); @@ -139,7 +139,7 @@ TEST(CachedCredentials, GetTokenExpiredWithError) { TEST(CachedCredentials, SignBlob) { auto mock = std::make_shared(); auto const expected = std::vector{1, 2, 3}; - EXPECT_CALL(*mock, SignBlob(absl::make_optional(std::string("test-account")), + EXPECT_CALL(*mock, SignBlob(std::make_optional(std::string("test-account")), "test-blob")) .WillOnce(Return(expected)); CachedCredentials tested(mock); diff --git a/google/cloud/internal/oauth2_compute_engine_credentials.h b/google/cloud/internal/oauth2_compute_engine_credentials.h index add952892db64..786320f71280b 100644 --- a/google/cloud/internal/oauth2_compute_engine_credentials.h +++ b/google/cloud/internal/oauth2_compute_engine_credentials.h @@ -19,9 +19,9 @@ #include "google/cloud/internal/oauth2_http_client_factory.h" #include "google/cloud/status.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include +#include #include namespace google { @@ -164,9 +164,9 @@ class ComputeEngineCredentials : public Credentials { mutable std::set scopes_; mutable std::string service_account_email_; mutable std::mutex universe_domain_mu_; - mutable absl::optional universe_domain_; + mutable std::optional universe_domain_; mutable std::mutex project_id_mu_; - mutable absl::optional project_id_; + mutable std::optional project_id_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/oauth2_credentials.cc b/google/cloud/internal/oauth2_credentials.cc index 4f85f961640f5..fed63cc07e6b6 100644 --- a/google/cloud/internal/oauth2_credentials.cc +++ b/google/cloud/internal/oauth2_credentials.cc @@ -41,7 +41,7 @@ Credentials::AuthenticationHeaders(std::chrono::system_clock::time_point tp, } StatusOr> Credentials::SignBlob( - absl::optional const&, std::string const&) const { + std::optional const&, std::string const&) const { return internal::UnimplementedError( "The current credentials cannot sign blobs locally", GCP_ERROR_INFO()); } diff --git a/google/cloud/internal/oauth2_credentials.h b/google/cloud/internal/oauth2_credentials.h index 7b8ece8c00ed0..a656e0a0d37f5 100644 --- a/google/cloud/internal/oauth2_credentials.h +++ b/google/cloud/internal/oauth2_credentials.h @@ -95,7 +95,7 @@ class Credentials { * mismatch. */ virtual StatusOr> SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const; /// Return the account's email associated with these credentials, if any. diff --git a/google/cloud/internal/oauth2_external_account_credentials.cc b/google/cloud/internal/oauth2_external_account_credentials.cc index 98ebd24d6ecc1..84513772cda49 100644 --- a/google/cloud/internal/oauth2_external_account_credentials.cc +++ b/google/cloud/internal/oauth2_external_account_credentials.cc @@ -187,7 +187,7 @@ StatusOr ParseExternalAccountConfiguration( MakeExternalAccountTokenSource(*credential_source, *audience, ec); if (!source) return std::move(source).status(); - absl::optional workforce_pool_user_project; + std::optional workforce_pool_user_project; auto it = json.find("workforce_pool_user_project"); if (it != json.end()) { workforce_pool_user_project = it->get(); @@ -197,7 +197,7 @@ StatusOr ParseExternalAccountConfiguration( *std::move(subject_token_type), *std::move(token_url), *std::move(source), - absl::nullopt, + std::nullopt, *std::move(universe_domain), std::move(workforce_pool_user_project), std::move(identity_federation)}; diff --git a/google/cloud/internal/oauth2_external_account_credentials_test.cc b/google/cloud/internal/oauth2_external_account_credentials_test.cc index 5e74a0a7f2904..c0ace07a83a0c 100644 --- a/google/cloud/internal/oauth2_external_account_credentials_test.cc +++ b/google/cloud/internal/oauth2_external_account_credentials_test.cc @@ -725,9 +725,9 @@ TEST(ExternalAccount, Working) { "test-subject-token-type", test_url, mock_source, - absl::nullopt, + std::nullopt, {}, - absl::nullopt, + std::nullopt, WorkloadIdentityFederationInfo{"$PROJECT_NUMBER", "$POOL_ID"}}; MockClientFactory client_factory; @@ -787,7 +787,7 @@ TEST(ExternalAccount, WorkingWorkforceIdentity) { "test-subject-token-type", test_url, mock_source, - absl::nullopt, + std::nullopt, {}, "project-id-or-name", WorkforceIdentityFederationInfo{"$POOL_ID"}}; @@ -878,7 +878,7 @@ TEST(ExternalAccount, WorkingWithImpersonation) { impersonate_test_url, impersonate_test_email, impersonate_test_lifetime}, {}, - absl::nullopt, + std::nullopt, std::monostate{}}; auto sts_client = [&] { @@ -959,8 +959,8 @@ TEST(ExternalAccount, HandleHttpError) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -998,8 +998,8 @@ TEST(ExternalAccount, HandleHttpPartialError) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1038,8 +1038,8 @@ TEST(ExternalAccount, HandleNotJson) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1078,8 +1078,8 @@ TEST(ExternalAccount, HandleNotJsonObject) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1124,8 +1124,8 @@ TEST(ExternalAccount, MissingToken) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1159,8 +1159,8 @@ TEST(ExternalAccount, MissingIssuedTokenType) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1194,8 +1194,8 @@ TEST(ExternalAccount, MissingTokenType) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1229,8 +1229,8 @@ TEST(ExternalAccount, InvalidIssuedTokenType) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1266,8 +1266,8 @@ TEST(ExternalAccount, InvalidTokenType) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1304,8 +1304,8 @@ TEST(ExternalAccount, MissingExpiresIn) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); @@ -1340,8 +1340,8 @@ TEST(ExternalAccount, InvalidExpiresIn) { auto const info = ExternalAccountInfo{"test-audience", "test-subject-token-type", test_url, mock_source, - absl::nullopt, {}, - absl::nullopt, std::monostate{}}; + std::nullopt, {}, + std::nullopt, std::monostate{}}; MockClientFactory client_factory; EXPECT_CALL(client_factory, Call).WillOnce([&]() { auto mock = std::make_unique(); diff --git a/google/cloud/internal/oauth2_impersonate_service_account_credentials.h b/google/cloud/internal/oauth2_impersonate_service_account_credentials.h index c5d656ef7c589..bd8a392fadf17 100644 --- a/google/cloud/internal/oauth2_impersonate_service_account_credentials.h +++ b/google/cloud/internal/oauth2_impersonate_service_account_credentials.h @@ -30,7 +30,7 @@ struct ImpersonatedServiceAccountCredentialsInfo { std::string service_account; std::vector delegates; std::vector scopes; - absl::optional quota_project_id; + std::optional quota_project_id; std::string source_credentials; }; diff --git a/google/cloud/internal/oauth2_logging_credentials.cc b/google/cloud/internal/oauth2_logging_credentials.cc index 8d62adb6a0fc8..1bbb1f1ddc820 100644 --- a/google/cloud/internal/oauth2_logging_credentials.cc +++ b/google/cloud/internal/oauth2_logging_credentials.cc @@ -55,7 +55,7 @@ StatusOr LoggingCredentials::GetToken( } StatusOr> LoggingCredentials::SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const { GCP_LOG(DEBUG) << __func__ << "(" << phase_ << "), signing_service_account=" << signing_service_account.value_or("") diff --git a/google/cloud/internal/oauth2_logging_credentials.h b/google/cloud/internal/oauth2_logging_credentials.h index 076a6bb6b881f..f2e88d29ab0a0 100644 --- a/google/cloud/internal/oauth2_logging_credentials.h +++ b/google/cloud/internal/oauth2_logging_credentials.h @@ -50,7 +50,7 @@ class LoggingCredentials : public Credentials { StatusOr GetToken( std::chrono::system_clock::time_point now) override; StatusOr> SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const override; std::string AccountEmail() const override; std::string KeyId() const override; diff --git a/google/cloud/internal/oauth2_logging_credentials_test.cc b/google/cloud/internal/oauth2_logging_credentials_test.cc index 98a17d9a059e4..0250452f05fae 100644 --- a/google/cloud/internal/oauth2_logging_credentials_test.cc +++ b/google/cloud/internal/oauth2_logging_credentials_test.cc @@ -40,7 +40,7 @@ class MockCredentials : public Credentials { MOCK_METHOD(StatusOr, GetToken, (std::chrono::system_clock::time_point), (override)); MOCK_METHOD(StatusOr>, SignBlob, - (absl::optional const&, std::string const&), + (std::optional const&, std::string const&), (const, override)); MOCK_METHOD(std::string, AccountEmail, (), (const, override)); MOCK_METHOD(std::string, KeyId, (), (const, override)); @@ -107,7 +107,7 @@ TEST(LoggingCredentials, GetTokenError) { TEST(LoggingCredentials, SignBlob) { auto mock = std::make_shared(); auto const expected = std::vector{1, 2, 3}; - EXPECT_CALL(*mock, SignBlob(absl::make_optional(std::string("test-account")), + EXPECT_CALL(*mock, SignBlob(std::make_optional(std::string("test-account")), "test-blob")) .WillOnce(Return(expected)); ScopedLog log; @@ -123,11 +123,11 @@ TEST(LoggingCredentials, SignBlob) { TEST(LoggingCredentials, SignBlobOptional) { auto mock = std::make_shared(); auto const expected = std::vector{1, 2, 3}; - EXPECT_CALL(*mock, SignBlob(absl::optional{}, "test-blob")) + EXPECT_CALL(*mock, SignBlob(std::optional{}, "test-blob")) .WillOnce(Return(expected)); ScopedLog log; LoggingCredentials tested("testing", TracingOptions(), mock); - auto actual = tested.SignBlob(absl::nullopt, "test-blob"); + auto actual = tested.SignBlob(std::nullopt, "test-blob"); ASSERT_STATUS_OK(actual); EXPECT_THAT(log.ExtractLines(), Contains(AllOf(HasSubstr("SignBlob(testing)"), diff --git a/google/cloud/internal/oauth2_regional_access_boundary_token_manager.cc b/google/cloud/internal/oauth2_regional_access_boundary_token_manager.cc index ad0dabb8f681b..c2c5640a7bb7f 100644 --- a/google/cloud/internal/oauth2_regional_access_boundary_token_manager.cc +++ b/google/cloud/internal/oauth2_regional_access_boundary_token_manager.cc @@ -218,7 +218,7 @@ RegionalAccessBoundaryTokenManager::AllowedLocations( StatusOr> RegionalAccessBoundaryTokenManager::SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const { return child_->SignBlob(signing_service_account, string_to_sign); } diff --git a/google/cloud/internal/oauth2_regional_access_boundary_token_manager.h b/google/cloud/internal/oauth2_regional_access_boundary_token_manager.h index 10d8a13c3faf0..dacbbe239aa61 100644 --- a/google/cloud/internal/oauth2_regional_access_boundary_token_manager.h +++ b/google/cloud/internal/oauth2_regional_access_boundary_token_manager.h @@ -81,7 +81,7 @@ class RegionalAccessBoundaryTokenManager // Decorator overrides from Credentials that simply call the same method on // child_. StatusOr> SignBlob( - absl::optional const& signing_service_account, + std::optional const& signing_service_account, std::string const& string_to_sign) const override; std::string AccountEmail() const override; std::string KeyId() const override; diff --git a/google/cloud/internal/oauth2_regional_access_boundary_token_manager_test.cc b/google/cloud/internal/oauth2_regional_access_boundary_token_manager_test.cc index 081b8412dfa84..a0dad5e60be1c 100644 --- a/google/cloud/internal/oauth2_regional_access_boundary_token_manager_test.cc +++ b/google/cloud/internal/oauth2_regional_access_boundary_token_manager_test.cc @@ -37,7 +37,7 @@ using ::testing::Return; class MockCredentials : public Credentials { public: MOCK_METHOD(StatusOr>, SignBlob, - (absl::optional const&, std::string const&), + (std::optional const&, std::string const&), (const, override)); MOCK_METHOD(std::string, AccountEmail, (), (const, override)); MOCK_METHOD(std::string, KeyId, (), (const, override)); diff --git a/google/cloud/internal/oauth2_service_account_credentials.cc b/google/cloud/internal/oauth2_service_account_credentials.cc index 9bfb7281eaf69..48d2416e4741c 100644 --- a/google/cloud/internal/oauth2_service_account_credentials.cc +++ b/google/cloud/internal/oauth2_service_account_credentials.cc @@ -330,7 +330,7 @@ StatusOr ServiceAccountCredentials::GetToken( } StatusOr> ServiceAccountCredentials::SignBlob( - absl::optional const& signing_account, + std::optional const& signing_account, std::string const& blob) const { if (signing_account.has_value() && signing_account.value() != info_.client_email) { diff --git a/google/cloud/internal/oauth2_service_account_credentials.h b/google/cloud/internal/oauth2_service_account_credentials.h index 748af3e9903d5..70763278dde7a 100644 --- a/google/cloud/internal/oauth2_service_account_credentials.h +++ b/google/cloud/internal/oauth2_service_account_credentials.h @@ -21,8 +21,8 @@ #include "google/cloud/optional.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include +#include #include #include #include @@ -49,12 +49,12 @@ struct ServiceAccountCredentialsInfo { std::string private_key; std::string token_uri; // If no set is supplied, a default set of scopes will be used. - absl::optional> scopes; + std::optional> scopes; // See https://developers.google.com/identity/protocols/OAuth2ServiceAccount. - absl::optional subject; + std::optional subject; bool enable_self_signed_jwt; - absl::optional universe_domain; - absl::optional project_id; + std::optional universe_domain; + std::optional project_id; }; /// Indicates whether or not to use a self-signed JWT or issue a request to @@ -280,7 +280,7 @@ class ServiceAccountCredentials : public oauth2_internal::Credentials { * does not match the email for the credential's account. */ StatusOr> SignBlob( - absl::optional const& signing_account, + std::optional const& signing_account, std::string const& blob) const override; std::string AccountEmail() const override { return info_.client_email; } diff --git a/google/cloud/internal/oauth2_service_account_credentials_test.cc b/google/cloud/internal/oauth2_service_account_credentials_test.cc index 07531618f20f5..1fe976343bc09 100644 --- a/google/cloud/internal/oauth2_service_account_credentials_test.cc +++ b/google/cloud/internal/oauth2_service_account_credentials_test.cc @@ -355,7 +355,7 @@ TEST(ServiceAccountCredentialsTest, /// @test Verify that ServiceAccountCredentials defaults to self-signed JWTs. TEST(ServiceAccountCredentialsTest, RefreshWithSelfSignedJWT) { ScopedEnvironment disable_self_signed_jwt( - "GOOGLE_CLOUD_CPP_EXPERIMENTAL_DISABLE_SELF_SIGNED_JWT", absl::nullopt); + "GOOGLE_CLOUD_CPP_EXPERIMENTAL_DISABLE_SELF_SIGNED_JWT", std::nullopt); auto info = ParseServiceAccountCredentials(MakeUniverseDomainTestContents(), "test"); @@ -536,7 +536,7 @@ TEST(ServiceAccountCredentialsTest, ParseMissingProjectId) { auto actual = ParseServiceAccountCredentials(contents, "test-data", "unused-uri"); ASSERT_STATUS_OK(actual); - EXPECT_EQ(actual->project_id, absl::nullopt); + EXPECT_EQ(actual->project_id, std::nullopt); } /// @test Verify that invalid contents result in a readable error. @@ -710,7 +710,7 @@ TEST(ServiceAccountCredentialsTest, UniverseDomainAccessorCustom) { TEST(ServiceAccountCredentialsTest, UniverseDomainAccessorFailure) { auto info = ParseServiceAccountCredentials(MakeTestContents(), "test"); - info->universe_domain = absl::nullopt; + info->universe_domain = std::nullopt; ASSERT_STATUS_OK(info); MockHttpClientFactory mock_http_client_factory; EXPECT_CALL(mock_http_client_factory, Call).Times(0); diff --git a/google/cloud/internal/openssl/parse_service_account_p12_file.cc b/google/cloud/internal/openssl/parse_service_account_p12_file.cc index 6683f636857a1..bb0462dcf016d 100644 --- a/google/cloud/internal/openssl/parse_service_account_p12_file.cc +++ b/google/cloud/internal/openssl/parse_service_account_p12_file.cc @@ -132,8 +132,8 @@ StatusOr ParseServiceAccountP12File( /*scopes=*/{}, /*subject=*/{}, /*enable_self_signed_jwt=*/false, - /*universe_domain=*/absl::nullopt, - /*project_id=*/absl::nullopt}; + /*universe_domain=*/std::nullopt, + /*project_id=*/std::nullopt}; } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/populate_common_options_test.cc b/google/cloud/internal/populate_common_options_test.cc index 6b5842b4342ee..a8701ed08927f 100644 --- a/google/cloud/internal/populate_common_options_test.cc +++ b/google/cloud/internal/populate_common_options_test.cc @@ -21,8 +21,8 @@ #include "google/cloud/testing_util/credentials.h" #include "google/cloud/testing_util/scoped_environment.h" #include "google/cloud/universe_domain_options.h" -#include "absl/types/optional.h" #include +#include namespace google { namespace cloud { @@ -39,8 +39,8 @@ using ::testing::IsEmpty; TEST(PopulateCommonOptions, Simple) { // Unset all the relevant environment variables. - ScopedEnvironment user("GOOGLE_CLOUD_CPP_USER_PROJECT", absl::nullopt); - ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_ENABLE_TRACING", absl::nullopt); + ScopedEnvironment user("GOOGLE_CLOUD_CPP_USER_PROJECT", std::nullopt); + ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_ENABLE_TRACING", std::nullopt); auto actual = PopulateCommonOptions(Options{}, {}, {}, {}, "default.googleapis.com"); EXPECT_TRUE(actual.has()); @@ -103,9 +103,9 @@ TEST(PopulateCommonOptions, EndpointAuthority) { .set("endpoint_option") .set("authority_option"), }; - absl::optional endpoints[] = {absl::nullopt, "", "endpoint"}; - absl::optional emulators[] = {absl::nullopt, "", "emulator"}; - absl::optional authorities[] = {absl::nullopt, "", "authority"}; + std::optional endpoints[] = {std::nullopt, "", "endpoint"}; + std::optional emulators[] = {std::nullopt, "", "emulator"}; + std::optional authorities[] = {std::nullopt, "", "authority"}; for (auto const& options : optionses) { for (auto const& endpoint_env : endpoints) { for (auto const& emulator_env : emulators) { @@ -163,8 +163,8 @@ TEST(PopulateCommonOptions, UniverseDomainEnvVar) { } TEST(PopulateCommonOptions, EndpointOptionsOverrideUniverseDomain) { - for (auto const& e : std::vector>{ - absl::nullopt, "ud-env-var.net"}) { + for (auto const& e : std::vector>{ + std::nullopt, "ud-env-var.net"}) { ScopedEnvironment ud("GOOGLE_CLOUD_UNIVERSE_DOMAIN", e); auto actual = PopulateCommonOptions( @@ -203,7 +203,7 @@ TEST(PopulateCommonOptions, UserProject) { Options{}, Options{}.set("project_option"), }; - absl::optional projects[] = {absl::nullopt, "", "project"}; + std::optional projects[] = {std::nullopt, "", "project"}; for (auto const& options : optionses) { for (auto const& project_env : projects) { ScopedEnvironment projects("GOOGLE_CLOUD_CPP_USER_PROJECT", project_env); @@ -222,7 +222,7 @@ TEST(PopulateCommonOptions, UserProject) { } TEST(PopulateCommonOptions, QuotaProjectEnvVar) { - ScopedEnvironment e1("GOOGLE_CLOUD_CPP_USER_PROJECT", absl::nullopt); + ScopedEnvironment e1("GOOGLE_CLOUD_CPP_USER_PROJECT", std::nullopt); ScopedEnvironment e2("GOOGLE_CLOUD_QUOTA_PROJECT", "env"); auto opts = Options{}.set("option"); @@ -233,11 +233,11 @@ TEST(PopulateCommonOptions, QuotaProjectEnvVar) { TEST(PopulateCommonOptions, OpenTelemetryTracing) { struct TestCase { - absl::optional env; + std::optional env; bool value; }; std::vector tests = { - {absl::nullopt, false}, + {std::nullopt, false}, {"", false}, {"ON", true}, }; @@ -250,7 +250,7 @@ TEST(PopulateCommonOptions, OpenTelemetryTracing) { } TEST(DefaultTracingComponents, NoEnvironment) { - ScopedEnvironment env("GOOGLE_CLOUD_CPP_ENABLE_TRACING", absl::nullopt); + ScopedEnvironment env("GOOGLE_CLOUD_CPP_ENABLE_TRACING", std::nullopt); auto const actual = DefaultTracingComponents(); EXPECT_THAT(actual, ElementsAre()); } @@ -262,7 +262,7 @@ TEST(DefaultTracingComponents, WithValue) { } TEST(DefaultTracingOptions, NoEnvironment) { - ScopedEnvironment env("GOOGLE_CLOUD_CPP_TRACING_OPTIONS", absl::nullopt); + ScopedEnvironment env("GOOGLE_CLOUD_CPP_TRACING_OPTIONS", std::nullopt); auto const actual = DefaultTracingOptions(); auto const expected = TracingOptions{}; EXPECT_EQ(expected.single_line_mode(), actual.single_line_mode()); diff --git a/google/cloud/internal/populate_grpc_options_test.cc b/google/cloud/internal/populate_grpc_options_test.cc index 0a72634ece410..cb6d24891a057 100644 --- a/google/cloud/internal/populate_grpc_options_test.cc +++ b/google/cloud/internal/populate_grpc_options_test.cc @@ -19,8 +19,8 @@ #include "google/cloud/internal/populate_common_options.h" #include "google/cloud/testing_util/credentials.h" #include "google/cloud/testing_util/scoped_environment.h" -#include "absl/types/optional.h" #include +#include namespace google { namespace cloud { @@ -33,7 +33,7 @@ using ::google::cloud::testing_util::TestCredentialsVisitor; TEST(PopulateGrpcOptions, Simple) { // Unset any environment variables - ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_TRACING_OPTIONS", absl::nullopt); + ScopedEnvironment tracing("GOOGLE_CLOUD_CPP_TRACING_OPTIONS", std::nullopt); auto actual = PopulateGrpcOptions(Options{}); EXPECT_TRUE(actual.has()); EXPECT_EQ(actual.get() diff --git a/google/cloud/internal/populate_rest_options_test.cc b/google/cloud/internal/populate_rest_options_test.cc index 1a60cb90df57d..402805fb06dfa 100644 --- a/google/cloud/internal/populate_rest_options_test.cc +++ b/google/cloud/internal/populate_rest_options_test.cc @@ -20,8 +20,8 @@ #include "google/cloud/rest_options.h" #include "google/cloud/testing_util/credentials.h" #include "google/cloud/testing_util/scoped_environment.h" -#include "absl/types/optional.h" #include +#include namespace google { namespace cloud { diff --git a/google/cloud/internal/rest_context.h b/google/cloud/internal/rest_context.h index 780207cb48113..f06e243421430 100644 --- a/google/cloud/internal/rest_context.h +++ b/google/cloud/internal/rest_context.h @@ -18,8 +18,8 @@ #include "google/cloud/internal/http_header.h" #include "google/cloud/options.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include +#include #include #include @@ -59,17 +59,17 @@ class RestContext { // Header names are case-insensitive; header values are case-sensitive. HttpHeader GetHeader(HttpHeaderName const& header) const; - absl::optional local_ip_address() const { + std::optional local_ip_address() const { return local_ip_address_; } void reset_local_ip_address() { local_ip_address_.reset(); } void set_local_ip_address(std::string a) { local_ip_address_ = std::move(a); } - absl::optional local_port() const { return local_port_; } + std::optional local_port() const { return local_port_; } void reset_local_port() { local_port_.reset(); } void set_local_port(std::int32_t p) { local_port_ = p; } - absl::optional primary_ip_address() const { + std::optional primary_ip_address() const { return primary_ip_address_; } void reset_primary_ip_address() { primary_ip_address_.reset(); } @@ -77,12 +77,12 @@ class RestContext { primary_ip_address_ = std::move(a); } - absl::optional primary_port() const { return primary_port_; } + std::optional primary_port() const { return primary_port_; } void reset_primary_port() { primary_port_.reset(); } void set_primary_port(std::int32_t p) { primary_port_ = p; } // The time spent in DNS lookups - absl::optional namelookup_time() const { + std::optional namelookup_time() const { return namelookup_time_; } void reset_namelookup_time() { namelookup_time_.reset(); } @@ -91,14 +91,14 @@ class RestContext { } // The time spent setting the TCP/IP connection. - absl::optional connect_time() const { + std::optional connect_time() const { return connect_time_; } void reset_connect_time() { connect_time_.reset(); } void set_connect_time(std::chrono::microseconds us) { connect_time_ = us; } // The time spent in the SSL handshake. - absl::optional appconnect_time() const { + std::optional appconnect_time() const { return appconnect_time_; } void reset_appconnect_time() { appconnect_time_.reset(); } @@ -110,13 +110,13 @@ class RestContext { friend bool operator==(RestContext const& lhs, RestContext const& rhs); Options options_; HttpHeaders headers_; - absl::optional local_ip_address_; - absl::optional local_port_; - absl::optional primary_ip_address_; - absl::optional primary_port_; - absl::optional namelookup_time_; - absl::optional connect_time_; - absl::optional appconnect_time_; + std::optional local_ip_address_; + std::optional local_port_; + std::optional primary_ip_address_; + std::optional primary_port_; + std::optional namelookup_time_; + std::optional connect_time_; + std::optional appconnect_time_; }; bool operator==(RestContext const& lhs, RestContext const& rhs); diff --git a/google/cloud/internal/resumable_streaming_read_rpc.h b/google/cloud/internal/resumable_streaming_read_rpc.h index 43d352fbae14c..560999f30aa93 100644 --- a/google/cloud/internal/resumable_streaming_read_rpc.h +++ b/google/cloud/internal/resumable_streaming_read_rpc.h @@ -91,12 +91,12 @@ class ResumableStreamingReadRpc : public StreamingReadRpc { void Cancel() override { impl_->Cancel(); } - absl::optional Read(ResponseType* response) override { + std::optional Read(ResponseType* response) override { auto opt_status = impl_->Read(response); if (!opt_status.has_value()) { updater_(*response, request_); has_received_data_ = true; - return absl::nullopt; + return std::nullopt; } auto last_status = *opt_status; if (last_status.ok()) return last_status; @@ -122,7 +122,7 @@ class ResumableStreamingReadRpc : public StreamingReadRpc { if (!next_opt_status.has_value()) { updater_(*response, request_); has_received_data_ = true; - return absl::nullopt; + return std::nullopt; } last_status = *std::move(next_opt_status); } diff --git a/google/cloud/internal/resumable_streaming_read_rpc_test.cc b/google/cloud/internal/resumable_streaming_read_rpc_test.cc index 25cb3cd9f0ecd..99568c1a0142e 100644 --- a/google/cloud/internal/resumable_streaming_read_rpc_test.cc +++ b/google/cloud/internal/resumable_streaming_read_rpc_test.cc @@ -44,7 +44,7 @@ struct FakeResponse { class MockStreamingReadRpc : public StreamingReadRpc { public: MOCK_METHOD(void, Cancel, (), (override)); - MOCK_METHOD(absl::optional, Read, (FakeResponse*), (override)); + MOCK_METHOD(std::optional, Read, (FakeResponse*), (override)); MOCK_METHOD(RpcMetadata, GetRequestMetadata, (), (const, override)); }; @@ -96,11 +96,11 @@ TEST(ResumableStreamingReadRpc, ResumeWithPartials) { EXPECT_CALL(*stream, Read) .WillOnce([](FakeResponse* r) { *r = FakeResponse{"value-0", "token-1"}; - return absl::nullopt; + return std::nullopt; }) .WillOnce([](FakeResponse* r) { *r = FakeResponse{"value-1", "token-2"}; - return absl::nullopt; + return std::nullopt; }) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))); return stream; @@ -112,7 +112,7 @@ TEST(ResumableStreamingReadRpc, ResumeWithPartials) { EXPECT_CALL(*stream, Read) .WillOnce([](FakeResponse* r) { *r = FakeResponse{"value-2", "token-2"}; - return absl::nullopt; + return std::nullopt; }) .WillOnce(Return(Status{})); return stream; @@ -160,7 +160,7 @@ TEST(ResumableStreamingReadRpc, TooManyTransientFailures) { EXPECT_CALL(*stream, Read) .WillOnce([](FakeResponse* r) { *r = FakeResponse{"value-0", "token-1"}; - return absl::nullopt; + return std::nullopt; }) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))); return stream; @@ -215,7 +215,7 @@ TEST(ResumableStreamingReadRpc, PermanentFailure) { EXPECT_CALL(*stream, Read) .WillOnce([](FakeResponse* r) { *r = FakeResponse{"value-0", "token-1"}; - return absl::nullopt; + return std::nullopt; }) .WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh"))); return stream; diff --git a/google/cloud/internal/routing_matcher.h b/google/cloud/internal/routing_matcher.h index b438f6fb87d5d..c43f8a089ffae 100644 --- a/google/cloud/internal/routing_matcher.h +++ b/google/cloud/internal/routing_matcher.h @@ -18,8 +18,8 @@ #include "google/cloud/internal/url_encode.h" #include "google/cloud/version.h" #include "absl/strings/str_cat.h" -#include "absl/types/optional.h" #include +#include #include #include #include @@ -40,7 +40,7 @@ struct RoutingMatcher { struct Pattern { std::function field_getter; - absl::optional re; + std::optional re; }; std::vector patterns; diff --git a/google/cloud/internal/routing_matcher_test.cc b/google/cloud/internal/routing_matcher_test.cc index 9072130e29f38..7a0f915fa5677 100644 --- a/google/cloud/internal/routing_matcher_test.cc +++ b/google/cloud/internal/routing_matcher_test.cc @@ -55,7 +55,7 @@ TEST(RoutingMatcher, MatchesAll) { {[](TestRequest const& request) -> std::string const& { return request.foo(); }, - absl::nullopt}, + std::nullopt}, }}; std::vector params = {"previous"}; @@ -71,7 +71,7 @@ TEST(RoutingMatcher, EmptyFieldIsSkipped) { {[](TestRequest const& request) -> std::string const& { return request.foo(); }, - absl::nullopt}, + std::nullopt}, {[](TestRequest const& request) -> std::string const& { return request.bar(); }, @@ -111,7 +111,7 @@ TEST(RoutingMatcher, UrlEncodesMatchAll) { {[](TestRequest const& request) -> std::string const& { return request.foo(); }, - absl::nullopt}, + std::nullopt}, }}; std::vector params = {"previous"}; diff --git a/google/cloud/internal/streaming_read_rpc.h b/google/cloud/internal/streaming_read_rpc.h index 764ff20a5c890..366e760235d2e 100644 --- a/google/cloud/internal/streaming_read_rpc.h +++ b/google/cloud/internal/streaming_read_rpc.h @@ -21,10 +21,10 @@ #include "google/cloud/rpc_metadata.h" #include "google/cloud/status.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include #include +#include #include namespace google { @@ -54,7 +54,7 @@ class StreamingReadRpc { /// Populates the next element and returns nullopt, or the final RPC status in /// the optional. - virtual absl::optional Read(ResponseType* response) = 0; + virtual std::optional Read(ResponseType* response) = 0; /** * Return the request metadata. @@ -93,8 +93,8 @@ class StreamingReadRpcImpl : public StreamingReadRpc { void Cancel() override { context_->TryCancel(); } - absl::optional Read(ResponseType* response) override { - if (stream_->Read(response)) return absl::nullopt; + std::optional Read(ResponseType* response) override { + if (stream_->Read(response)) return std::nullopt; return Finish(); } @@ -134,7 +134,7 @@ class StreamingReadRpcError : public StreamingReadRpc { void Cancel() override {} - absl::optional Read(ResponseType* /*response*/) override { + std::optional Read(ResponseType* /*response*/) override { return status_; } diff --git a/google/cloud/internal/streaming_read_rpc_logging.h b/google/cloud/internal/streaming_read_rpc_logging.h index 8c228e952e406..4b3464196b8bc 100644 --- a/google/cloud/internal/streaming_read_rpc_logging.h +++ b/google/cloud/internal/streaming_read_rpc_logging.h @@ -22,10 +22,10 @@ #include "google/cloud/tracing_options.h" #include "google/cloud/version.h" #include "absl/strings/str_cat.h" -#include "absl/types/optional.h" #include #include #include +#include #include #include @@ -54,7 +54,7 @@ class StreamingReadRpcLogging : public StreamingReadRpc { reader_->Cancel(); GCP_LOG(DEBUG) << prefix << "() >> (void)"; } - absl::optional Read(ResponseType* response) override { + std::optional Read(ResponseType* response) override { auto const prefix = std::string(__func__) + "(" + request_id_ + ")"; GCP_LOG(DEBUG) << prefix << "() << (void)"; auto result = reader_->Read(response); diff --git a/google/cloud/internal/streaming_read_rpc_logging_test.cc b/google/cloud/internal/streaming_read_rpc_logging_test.cc index c2593db8e855c..a65b86a34990f 100644 --- a/google/cloud/internal/streaming_read_rpc_logging_test.cc +++ b/google/cloud/internal/streaming_read_rpc_logging_test.cc @@ -34,7 +34,7 @@ class MockStreamingReadRpc : public StreamingReadRpc { public: ~MockStreamingReadRpc() override = default; MOCK_METHOD(void, Cancel, (), (override)); - MOCK_METHOD(absl::optional, Read, (ResponseType*), (override)); + MOCK_METHOD(std::optional, Read, (ResponseType*), (override)); MOCK_METHOD(RpcMetadata, GetRequestMetadata, (), (const, override)); }; @@ -60,7 +60,7 @@ TEST_F(StreamingReadRpcLoggingTest, Read) { EXPECT_CALL(*mock, Read) .WillOnce([](google::protobuf::Duration* response) { response->set_seconds(42); - return absl::optional{}; + return std::optional{}; }) .WillOnce([](google::protobuf::Duration*) { return Status(StatusCode::kInvalidArgument, "Invalid argument."); diff --git a/google/cloud/internal/streaming_read_rpc_tracing.h b/google/cloud/internal/streaming_read_rpc_tracing.h index 71c885920fd71..c59d3dff718f8 100644 --- a/google/cloud/internal/streaming_read_rpc_tracing.h +++ b/google/cloud/internal/streaming_read_rpc_tracing.h @@ -46,7 +46,7 @@ class StreamingReadRpcTracing : public StreamingReadRpc { impl_->Cancel(); } - absl::optional Read(ResponseType* response) override { + std::optional Read(ResponseType* response) override { auto result = impl_->Read(response); if (result.has_value()) { return End(*result); diff --git a/google/cloud/internal/streaming_read_rpc_tracing_test.cc b/google/cloud/internal/streaming_read_rpc_tracing_test.cc index 7f7083adef5ac..578262b101369 100644 --- a/google/cloud/internal/streaming_read_rpc_tracing_test.cc +++ b/google/cloud/internal/streaming_read_rpc_tracing_test.cc @@ -45,7 +45,7 @@ class MockStreamingReadRpc : public StreamingReadRpc { public: ~MockStreamingReadRpc() override = default; MOCK_METHOD(void, Cancel, (), (override)); - MOCK_METHOD(absl::optional, Read, (ResponseType*), (override)); + MOCK_METHOD(std::optional, Read, (ResponseType*), (override)); MOCK_METHOD(RpcMetadata, GetRequestMetadata, (), (const, override)); }; @@ -101,9 +101,9 @@ TEST(StreamingReadRpcTracingTest, Read) { auto mock = std::make_unique>(); EXPECT_CALL(*mock, Read) - .WillOnce(DoAll(SetArgPointee<0>(100), Return(absl::nullopt))) - .WillOnce(DoAll(SetArgPointee<0>(200), Return(absl::nullopt))) - .WillOnce(DoAll(SetArgPointee<0>(300), Return(absl::nullopt))) + .WillOnce(DoAll(SetArgPointee<0>(100), Return(std::nullopt))) + .WillOnce(DoAll(SetArgPointee<0>(200), Return(std::nullopt))) + .WillOnce(DoAll(SetArgPointee<0>(300), Return(std::nullopt))) .WillOnce(Return(Status())); auto span = MakeSpan("span"); diff --git a/google/cloud/internal/unified_grpc_credentials.cc b/google/cloud/internal/unified_grpc_credentials.cc index ee6f587438d3e..42363ff631bcc 100644 --- a/google/cloud/internal/unified_grpc_credentials.cc +++ b/google/cloud/internal/unified_grpc_credentials.cc @@ -180,8 +180,8 @@ std::shared_ptr CreateAuthenticationStrategy( return std::make_shared(credentials); } -absl::optional LoadCAInfo(Options const& opts) { - if (!opts.has()) return absl::nullopt; +std::optional LoadCAInfo(Options const& opts) { + if (!opts.has()) return std::nullopt; std::ifstream is(opts.get()); return std::string{std::istreambuf_iterator{is.rdbuf()}, {}}; } diff --git a/google/cloud/internal/unified_grpc_credentials.h b/google/cloud/internal/unified_grpc_credentials.h index dc358b759e04a..b63475b39f9e8 100644 --- a/google/cloud/internal/unified_grpc_credentials.h +++ b/google/cloud/internal/unified_grpc_credentials.h @@ -20,9 +20,9 @@ #include "google/cloud/future.h" #include "google/cloud/status.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include +#include namespace google { namespace cloud { @@ -50,7 +50,7 @@ std::shared_ptr CreateAuthenticationStrategy( std::shared_ptr CreateAuthenticationStrategy( std::shared_ptr const& credentials); -absl::optional LoadCAInfo(Options const& opts); +std::optional LoadCAInfo(Options const& opts); } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/unified_rest_credentials_integration_test.cc b/google/cloud/internal/unified_rest_credentials_integration_test.cc index 4292f6ed1fd31..32f62c1e18bef 100644 --- a/google/cloud/internal/unified_rest_credentials_integration_test.cc +++ b/google/cloud/internal/unified_rest_credentials_integration_test.cc @@ -335,7 +335,7 @@ TEST(UnifiedRestCredentialsIntegrationTest, StorageServiceAccount) { TEST(UnifiedRestCredentialsIntegrationTest, BigQuerySelfSignedJWT) { ScopedEnvironment self_signed_jwt( - "GOOGLE_CLOUD_CPP_EXPERIMENTAL_DISABLE_SELF_SIGNED_JWT", absl::nullopt); + "GOOGLE_CLOUD_CPP_EXPERIMENTAL_DISABLE_SELF_SIGNED_JWT", std::nullopt); auto env = internal::GetEnv("GOOGLE_CLOUD_CPP_REST_TEST_KEY_FILE_JSON"); ASSERT_TRUE(env.has_value()); @@ -348,7 +348,7 @@ TEST(UnifiedRestCredentialsIntegrationTest, BigQuerySelfSignedJWT) { TEST(UnifiedRestCredentialsIntegrationTest, StorageSelfSignedJWT) { ScopedEnvironment self_signed_jwt( - "GOOGLE_CLOUD_CPP_EXPERIMENTAL_DISABLE_SELF_SIGNED_JWT", absl::nullopt); + "GOOGLE_CLOUD_CPP_EXPERIMENTAL_DISABLE_SELF_SIGNED_JWT", std::nullopt); auto env = internal::GetEnv("GOOGLE_CLOUD_CPP_REST_TEST_KEY_FILE_JSON"); ASSERT_TRUE(env.has_value()); diff --git a/google/cloud/internal/unified_rest_credentials_test.cc b/google/cloud/internal/unified_rest_credentials_test.cc index 1f9bdc380066f..7b9f057e1b6ee 100644 --- a/google/cloud/internal/unified_rest_credentials_test.cc +++ b/google/cloud/internal/unified_rest_credentials_test.cc @@ -262,7 +262,7 @@ TEST(UnifiedRestCredentialsTest, AdcIsAuthorizedUser) { TEST(UnifiedRestCredentialsTest, AdcIsComputeEngine) { auto const filename = TempKeyFileName(); auto const env = - ScopedEnvironment(oauth2_internal::GoogleAdcEnvVar(), absl::nullopt); + ScopedEnvironment(oauth2_internal::GoogleAdcEnvVar(), std::nullopt); auto const override_default_path = ScopedEnvironment(oauth2_internal::GoogleGcloudAdcFileEnvVar(), filename); auto const now = std::chrono::system_clock::now(); @@ -453,7 +453,7 @@ TEST(UnifiedRestCredentialsTest, ServiceAccount) { EXPECT_CALL(client_factory, Call).Times(0); auto const config = - internal::ServiceAccountConfig(contents.dump(), absl::nullopt, Options{}); + internal::ServiceAccountConfig(contents.dump(), std::nullopt, Options{}); auto credentials = MapCredentials(config, client_factory.AsStdFunction()); auto access_token = credentials->GetToken(now); ASSERT_STATUS_OK(access_token); diff --git a/google/cloud/log.cc b/google/cloud/log.cc index c93452e00ea2d..06307f5625a3c 100644 --- a/google/cloud/log.cc +++ b/google/cloud/log.cc @@ -54,7 +54,7 @@ std::array constexpr kSeverityNames{ "ERROR", "CRITICAL", "ALERT", "FATAL", }; -absl::optional ParseSize(std::string const& str) { +std::optional ParseSize(std::string const& str) { std::size_t econv = -1; auto const val = std::stol(str, &econv); if (econv != str.size()) return {}; @@ -64,7 +64,7 @@ absl::optional ParseSize(std::string const& str) { } // namespace -absl::optional ParseSeverity(std::string const& name) { +std::optional ParseSeverity(std::string const& name) { int i = 0; for (auto const* n : kSeverityNames) { if (name == n) return static_cast(i); diff --git a/google/cloud/log.h b/google/cloud/log.h index cdda995e98b39..06c8fa36bc690 100644 --- a/google/cloud/log.h +++ b/google/cloud/log.h @@ -16,7 +16,6 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOG_H #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -143,7 +143,7 @@ enum class Severity : int { }; /// Convert a human-readable representation to a Severity. -absl::optional ParseSeverity(std::string const& name); +std::optional ParseSeverity(std::string const& name); /// Streaming operator, writes a human-readable representation. std::ostream& operator<<(std::ostream& os, Severity x); diff --git a/google/cloud/log_test.cc b/google/cloud/log_test.cc index 2283032635562..1fbd11f8927e0 100644 --- a/google/cloud/log_test.cc +++ b/google/cloud/log_test.cc @@ -167,7 +167,7 @@ TEST(LogSinkTest, FlushMultipleBackends) { } TEST(LogSinkTest, LogDefaultInstance) { - ScopedEnvironment config(kLogConfig, absl::nullopt); + ScopedEnvironment config(kLogConfig, std::nullopt); ScopedEnvironment env(kEnableClog, "anyvalue"); auto backend = std::make_shared(); @@ -218,7 +218,7 @@ TEST(LogSinkTest, ClogEnvironment) { auto old_style = testing::FLAGS_gtest_death_test_style; testing::FLAGS_gtest_death_test_style = "threadsafe"; - ScopedEnvironment config(kLogConfig, absl::nullopt); + ScopedEnvironment config(kLogConfig, std::nullopt); ScopedEnvironment env(kEnableClog, "anyvalue"); auto f = [] { diff --git a/google/cloud/optional.h b/google/cloud/optional.h index e6fe96325d9e6..721dfcde67848 100644 --- a/google/cloud/optional.h +++ b/google/cloud/optional.h @@ -16,7 +16,7 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_OPTIONAL_H #include "google/cloud/version.h" -#include "absl/types/optional.h" +#include namespace google { namespace cloud { @@ -25,10 +25,10 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN /** * Alias template for google::cloud::optional. * - * @deprecated this alias is deprecated; use `absl::optional` directly. + * @deprecated this alias is deprecated; use `std::optional` directly. */ template -using optional = absl::optional; +using optional = std::optional; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud diff --git a/google/cloud/options.h b/google/cloud/options.h index def1f0ac76499..5d7cb10806e14 100644 --- a/google/cloud/options.h +++ b/google/cloud/options.h @@ -18,8 +18,8 @@ #include "google/cloud/internal/type_list.h" #include "google/cloud/version.h" #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include +#include #include #include #include @@ -38,9 +38,9 @@ void CheckExpectedOptionsImpl(std::set const&, Options const&, // TODO(#8800) - Remove when bigtable::Table no longer uses bigtable::DataClient bool IsEmpty(Options const&); template -absl::optional ExtractOption(Options&); +std::optional ExtractOption(Options&); template -absl::optional FetchOption(Options const&); +std::optional FetchOption(Options const&); template inline T const& DefaultValue() { static auto const* const kDefaultValue = new T{}; @@ -249,9 +249,9 @@ class Options { std::set const&, Options const&, char const*); friend bool internal::IsEmpty(Options const&); template - friend absl::optional internal::ExtractOption(Options&); + friend std::optional internal::ExtractOption(Options&); template - friend absl::optional internal::FetchOption(Options const&); + friend std::optional internal::FetchOption(Options const&); // The type-erased data holder of all the option values. class DataHolder { @@ -365,10 +365,10 @@ Options MergeOptions(Options preferred, Options alternatives); * mechanisms, rather than through an OptionsSpan. */ template -absl::optional ExtractOption(Options& opts) { +std::optional ExtractOption(Options& opts) { // Use std::unordered_map::extract() when minimum language version >= C++17. auto const it = opts.m_.find(typeid(T)); - if (it == opts.m_.end()) return absl::nullopt; + if (it == opts.m_.end()) return std::nullopt; auto dh = std::move(it->second); opts.m_.erase(it); return std::move(*reinterpret_cast(dh->data_address())); @@ -381,9 +381,9 @@ absl::optional ExtractOption(Options& opts) { * value. */ template -absl::optional FetchOption(Options const& opts) { +std::optional FetchOption(Options const& opts) { auto const it = opts.m_.find(typeid(T)); - if (it == opts.m_.end()) return absl::nullopt; + if (it == opts.m_.end()) return std::nullopt; return *reinterpret_cast(it->second->data_address()); } diff --git a/google/cloud/status.cc b/google/cloud/status.cc index a0bb828e4528f..55a1dd5bfb5ec 100644 --- a/google/cloud/status.cc +++ b/google/cloud/status.cc @@ -96,12 +96,12 @@ class Status::Impl { StatusCode code() const { return code_; } std::string const& message() const { return message_; } ErrorInfo const& error_info() const { return error_info_; } - absl::optional const& retry_info() const { + std::optional const& retry_info() const { return retry_info_; } // Allows mutable access to payload, which is needed in the // `internal::SetRetryInfo()` function. - absl::optional& retry_info() { return retry_info_; } + std::optional& retry_info() { return retry_info_; } PayloadType const& payload() const { return payload_; } // Allows mutable access to payload, which is needed in the @@ -120,7 +120,7 @@ class Status::Impl { StatusCode code_; std::string message_; ErrorInfo error_info_; - absl::optional retry_info_; + std::optional retry_info_; PayloadType payload_; }; @@ -188,13 +188,13 @@ void AddMetadata(ErrorInfo& ei, std::string const& key, std::string value) { ei.metadata_[key] = std::move(value); } -void SetRetryInfo(Status& status, absl::optional retry_info) { +void SetRetryInfo(Status& status, std::optional retry_info) { if (!status.impl_) return; status.impl_->retry_info() = std::move(retry_info); } -absl::optional GetRetryInfo(Status const& status) { - if (!status.impl_) return absl::nullopt; +std::optional GetRetryInfo(Status const& status) { + if (!status.impl_) return std::nullopt; return status.impl_->retry_info(); } @@ -207,12 +207,12 @@ void SetPayload(Status& s, std::string key, std::string payload) { } // Returns the payload associated with the given `key`, if available. -absl::optional GetPayload(Status const& s, +std::optional GetPayload(Status const& s, std::string const& key) { - if (!s.impl_) return absl::nullopt; + if (!s.impl_) return std::nullopt; auto const& payload = s.impl_->payload(); auto it = payload.find(key); - if (it == payload.end()) return absl::nullopt; + if (it == payload.end()) return std::nullopt; return it->second; } diff --git a/google/cloud/status.h b/google/cloud/status.h index 96f700f99850f..9029de01910f1 100644 --- a/google/cloud/status.h +++ b/google/cloud/status.h @@ -17,9 +17,9 @@ #include "google/cloud/internal/retry_info.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" #include #include +#include #include #include @@ -198,10 +198,10 @@ class Status; class ErrorInfo; namespace internal { void AddMetadata(ErrorInfo&, std::string const& key, std::string value); -void SetRetryInfo(Status& status, absl::optional retry_info); -absl::optional GetRetryInfo(Status const& status); +void SetRetryInfo(Status& status, std::optional retry_info); +std::optional GetRetryInfo(Status const& status); void SetPayload(Status&, std::string key, std::string payload); -absl::optional GetPayload(Status const&, std::string const& key); +std::optional GetPayload(Status const&, std::string const& key); } // namespace internal /** @@ -361,11 +361,11 @@ class Status { private: static bool Equals(Status const& a, Status const& b); friend void internal::SetRetryInfo(Status&, - absl::optional); - friend absl::optional internal::GetRetryInfo( + std::optional); + friend std::optional internal::GetRetryInfo( Status const&); friend void internal::SetPayload(Status&, std::string, std::string); - friend absl::optional internal::GetPayload(Status const&, + friend std::optional internal::GetPayload(Status const&, std::string const&); class Impl; diff --git a/google/cloud/status_or.h b/google/cloud/status_or.h index c8c5e3562af47..c2feb6f9ca7d6 100644 --- a/google/cloud/status_or.h +++ b/google/cloud/status_or.h @@ -18,7 +18,7 @@ #include "google/cloud/internal/throw_delegate.h" #include "google/cloud/status.h" #include "google/cloud/version.h" -#include "absl/types/optional.h" +#include #include #include @@ -302,7 +302,7 @@ class StatusOr final { } Status status_; - absl::optional value_; + std::optional value_; }; // Returns true IFF both `StatusOr` objects hold an equal `Status` or an diff --git a/google/cloud/status_test.cc b/google/cloud/status_test.cc index e4952b3c88629..e73b3ec4acee2 100644 --- a/google/cloud/status_test.cc +++ b/google/cloud/status_test.cc @@ -171,7 +171,7 @@ TEST(Status, RetryInfoIgnoredWithOk) { internal::SetRetryInfo(s, internal::RetryInfo{std::chrono::minutes(5)}); EXPECT_EQ(ok, s); auto ri = internal::GetRetryInfo(s); - EXPECT_EQ(ri, absl::nullopt); + EXPECT_EQ(ri, std::nullopt); } TEST(Status, RetryInfo) { diff --git a/google/cloud/tracing_options.cc b/google/cloud/tracing_options.cc index f41fc99a13e64..fae450f473d6c 100644 --- a/google/cloud/tracing_options.cc +++ b/google/cloud/tracing_options.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "google/cloud/tracing_options.h" -#include "absl/types/optional.h" #include #include +#include #include namespace google { @@ -23,7 +23,7 @@ namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -absl::optional ParseBoolean(std::string const& str) { +std::optional ParseBoolean(std::string const& str) { for (auto const* t : {"Y", "y", "T", "t", "1", "on"}) { if (str == t) return true; } @@ -33,7 +33,7 @@ absl::optional ParseBoolean(std::string const& str) { return {}; } -absl::optional ParseInteger(std::string const& str) { +std::optional ParseInteger(std::string const& str) { std::size_t econv = -1; auto val = std::stoll(str, &econv); if (econv != str.size()) return {};