Skip to content

Commit

Permalink
[base] Remove CHECKs in base::Optional operator* and ->
Browse files Browse the repository at this point in the history
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/1093314
Reviewed-by: Nico Weber <[email protected]>
Commit-Queue: Jan Wilken Dörrie <[email protected]>
Cr-Commit-Position: refs/heads/master@{#565720}
  • Loading branch information
jdoerrie authored and Commit Bot committed Jun 8, 2018
1 parent aa41655 commit a000101
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions base/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,32 +575,32 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
}

constexpr const T* operator->() const {
CHECK(storage_.is_populated_);
DCHECK(storage_.is_populated_);
return &storage_.value_;
}

constexpr T* operator->() {
CHECK(storage_.is_populated_);
DCHECK(storage_.is_populated_);
return &storage_.value_;
}

constexpr const T& operator*() const & {
CHECK(storage_.is_populated_);
DCHECK(storage_.is_populated_);
return storage_.value_;
}

constexpr T& operator*() & {
CHECK(storage_.is_populated_);
DCHECK(storage_.is_populated_);
return storage_.value_;
}

constexpr const T&& operator*() const && {
CHECK(storage_.is_populated_);
DCHECK(storage_.is_populated_);
return std::move(storage_.value_);
}

constexpr T&& operator*() && {
CHECK(storage_.is_populated_);
DCHECK(storage_.is_populated_);
return std::move(storage_.value_);
}

Expand Down

0 comments on commit a000101

Please sign in to comment.