Commit 67210f1c authored by Chad Austin's avatar Chad Austin Committed by Facebook Github Bot

allow conversion from nullptr to folly::Optional<bool>

Summary:
Disabling the nullptr conversion to non-pointer folly::Optional<T> has
baked long enough. Re-enabled it with the same behavior that
std::optional has.

Reviewed By: Orvid

Differential Revision: D15151503

fbshipit-source-id: d170f3f0e6bf3bb4461f17bdb6f8078b5a883615
parent 5f8a9671
...@@ -133,25 +133,6 @@ class Optional { ...@@ -133,25 +133,6 @@ class Optional {
construct(newValue); construct(newValue);
} }
/**
* Explicitly disallow converting nullptr to non-pointer
* types. Optional used to support initialization from nullptr as if
* it were folly::none. Without this constructor,
* folly::Optional<bool> could be constructed from nullptr,
* producing {false} instead of {}. This would be a change in
* behavior from the old code, so explicitly disallow it. Note that
* std::optional<bool> can be constructed from nullptr, also
* producing {false}.
*
* This constructor is temporary and should be removed when all call
* sites are fixed.
*/
template <typename Null = std::nullptr_t>
/* implicit */
Optional(typename std::enable_if<
std::is_convertible<Null, Value>::value,
Null>::type) noexcept = delete;
template <typename... Args> template <typename... Args>
constexpr explicit Optional(in_place_t, Args&&... args) noexcept( constexpr explicit Optional(in_place_t, Args&&... args) noexcept(
std::is_nothrow_constructible<Value, Args...>::value) std::is_nothrow_constructible<Value, Args...>::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