Remove explicit from Optional constructors

This allows base::nullopt to be used instead of base::Optional<Foo>()
and implicit conversion to Optional<T> from T.

Also added NOLINT comments to the implicit constructors.

Change-Id: I4c688045685e2a50e0c0d38a959570f77454ec61
Reviewed-on: https://chromium-review.googlesource.com/893268
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51003}
This commit is contained in:
Dan Elphick 2018-01-31 11:43:12 +00:00 committed by Commit Bot
parent dc08d4f870
commit 96dd41a3f4

View File

@ -125,7 +125,7 @@ class Optional {
constexpr Optional() {}
explicit constexpr Optional(base::nullopt_t) {}
constexpr Optional(base::nullopt_t) {} // NOLINT(runtime/explicit)
Optional(const Optional& other) {
if (!other.storage_.is_null_) Init(other.value());
@ -135,10 +135,12 @@ class Optional {
if (!other.storage_.is_null_) Init(std::move(other.value()));
}
explicit constexpr Optional(const T& value) : storage_(value) {}
constexpr Optional(const T& value) // NOLINT(runtime/explicit)
: storage_(value) {}
// TODO(alshabalin): Can't use 'constexpr' with std::move until C++14.
explicit Optional(T&& value) : storage_(std::move(value)) {}
Optional(T&& value) // NOLINT(runtime/explicit)
: storage_(std::move(value)) {}
// TODO(alshabalin): Can't use 'constexpr' with std::forward until C++14.
template <class... Args>