summaryrefslogtreecommitdiff
path: root/absl/types
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2018-05-11 05:42:49 -0700
committerGravatar jueminyang <jueminyang@google.com>2018-05-11 11:42:54 -0400
commitdd9911a004edcc34152850a6216bb3b53ad6bb82 (patch)
treeda942588037ba40fb501399b40c1fdec5431448f /absl/types
parent7454bdded7878b10dcdf8d5c64756c7a87e46500 (diff)
- da802ce3de569d5af0bfc5888c8a0d823548b544 Removes private method pointer() from optional and adds a... by Abseil Team <absl-team@google.com>
GitOrigin-RevId: da802ce3de569d5af0bfc5888c8a0d823548b544 Change-Id: Ic9c0a0771c90a5484b459655c8b25b36ffd8c3f0
Diffstat (limited to 'absl/types')
-rw-r--r--absl/types/optional.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/absl/types/optional.h b/absl/types/optional.h
index 4dcf4796..42068cca 100644
--- a/absl/types/optional.h
+++ b/absl/types/optional.h
@@ -776,10 +776,13 @@ class optional : private optional_internal::optional_data<T>,
// `optional` is empty, behavior is undefined.
//
// If you need myOpt->foo in constexpr, use (*myOpt).foo instead.
- const T* operator->() const { return this->pointer(); }
+ const T* operator->() const {
+ assert(this->engaged_);
+ return std::addressof(this->data_);
+ }
T* operator->() {
assert(this->engaged_);
- return this->pointer();
+ return std::addressof(this->data_);
}
// optional::operator*()
@@ -871,10 +874,6 @@ class optional : private optional_internal::optional_data<T>,
}
private:
- // Private accessors for internal storage viewed as pointer to T.
- const T* pointer() const { return std::addressof(this->data_); }
- T* pointer() { return std::addressof(this->data_); }
-
// Private accessors for internal storage viewed as reference to T.
constexpr const T& reference() const { return this->data_; }
T& reference() { return this->data_; }