Commit a000101f authored by jdoerrie's avatar jdoerrie Committed by Commit Bot

[base] Remove CHECKs in base::Optional operator* and ->

This change partially reverts r550197 which introduced CHECKs to
base::Optional's operator*, operator-> and value(). This is done to
reduce binary size and to be more standard's compliant, as std::optional
also doesn't perform checks for operator* and operator->. Lastly, the
CHECKs in value() are kept, as here CHECKing is desired, and also
matches std::optional's behaviour.

Bug: 832678
Change-Id: I467c7d7623c2880ee761b8a58a74738c09e0ba2a
Reviewed-on: https://chromium-review.googlesource.com/1093314Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565720}
parent aa416553
...@@ -575,32 +575,32 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -575,32 +575,32 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
} }
constexpr const T* operator->() const { constexpr const T* operator->() const {
CHECK(storage_.is_populated_); DCHECK(storage_.is_populated_);
return &storage_.value_; return &storage_.value_;
} }
constexpr T* operator->() { constexpr T* operator->() {
CHECK(storage_.is_populated_); DCHECK(storage_.is_populated_);
return &storage_.value_; return &storage_.value_;
} }
constexpr const T& operator*() const & { constexpr const T& operator*() const & {
CHECK(storage_.is_populated_); DCHECK(storage_.is_populated_);
return storage_.value_; return storage_.value_;
} }
constexpr T& operator*() & { constexpr T& operator*() & {
CHECK(storage_.is_populated_); DCHECK(storage_.is_populated_);
return storage_.value_; return storage_.value_;
} }
constexpr const T&& operator*() const && { constexpr const T&& operator*() const && {
CHECK(storage_.is_populated_); DCHECK(storage_.is_populated_);
return std::move(storage_.value_); return std::move(storage_.value_);
} }
constexpr T&& operator*() && { constexpr T&& operator*() && {
CHECK(storage_.is_populated_); DCHECK(storage_.is_populated_);
return std::move(storage_.value_); return std::move(storage_.value_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment