From 5ff8df71d48b7bb447dff2e98aa32a7f52640f12 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal <yashkt@google.com> Date: Fri, 26 Apr 2019 13:41:30 -0700 Subject: [PATCH] Add default constructor back to optional --- .../ext/filters/client_channel/resolver_result_parsing.cc | 6 +++--- src/core/lib/gprpp/optional.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.cc b/src/core/ext/filters/client_channel/resolver_result_parsing.cc index 35e54779c6..452dea6a0f 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.cc +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.cc @@ -416,8 +416,8 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, "field:retryThrottling error:Type should be object")); continue; } - Optional<int> max_milli_tokens = Optional<int>(); - Optional<int> milli_token_ratio = Optional<int>(); + Optional<int> max_milli_tokens; + Optional<int> milli_token_ratio; for (grpc_json* sub_field = field->child; sub_field != nullptr; sub_field = sub_field->next) { if (sub_field->key == nullptr) continue; @@ -535,7 +535,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); InlinedVector<grpc_error*, 4> error_list; - Optional<bool> wait_for_ready = Optional<bool>(); + Optional<bool> wait_for_ready; grpc_millis timeout = 0; UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> retry_policy; for (grpc_json* field = json->child; field != nullptr; field = field->next) { diff --git a/src/core/lib/gprpp/optional.h b/src/core/lib/gprpp/optional.h index a8e3ce1505..ab5f86393b 100644 --- a/src/core/lib/gprpp/optional.h +++ b/src/core/lib/gprpp/optional.h @@ -26,6 +26,7 @@ namespace grpc_core { template <typename T> class Optional { public: + Optional() : value_() {} void set(const T& val) { value_ = val; set_ = true; -- GitLab