Merge pull request #21342 from AspirinSJL/optional

Add move assignment method to Optional<>
reviewable/pr20638/r21^2
Juanli Shen 5 years ago committed by GitHub
commit 36b80dce90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/core/lib/gprpp/optional.h

@ -19,6 +19,10 @@
#ifndef GRPC_CORE_LIB_GPRPP_OPTIONAL_H
#define GRPC_CORE_LIB_GPRPP_OPTIONAL_H
#include <grpc/support/port_platform.h>
#include <utility>
namespace grpc_core {
/* A make-shift alternative for absl::Optional. This can be removed in favor of
@ -27,11 +31,17 @@ template <typename T>
class Optional {
public:
Optional() : value_() {}
void set(const T& val) {
value_ = val;
set_ = true;
}
void set(T&& val) {
value_ = std::move(val);
set_ = true;
}
bool has_value() const { return set_; }
void reset() { set_ = false; }

Loading…
Cancel
Save