Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: base/optional.h

Issue 2198673002: Implement Optional::has_value() and Optional::reset(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/optional_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/optional.h
diff --git a/base/optional.h b/base/optional.h
index b468964ae339fbead38f769dd315ff39a008d054..98cd95857094023fae865137d7b90838a93d986f 100644
--- a/base/optional.h
+++ b/base/optional.h
@@ -163,6 +163,8 @@ class Optional {
constexpr explicit operator bool() const { return !storage_.is_null_; }
+ constexpr bool has_value() const { return !storage_.is_null_; }
+
// TODO(mlamouri): using 'constexpr' here breaks compiler that assume it was
// meant to be 'constexpr const'.
T& value() & {
@@ -231,6 +233,10 @@ class Optional {
swap(**this, *other);
}
+ void reset() {
+ FreeIfNeeded();
+ }
+
template <class... Args>
void emplace(Args&&... args) {
FreeIfNeeded();
« no previous file with comments | « no previous file | base/optional_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698