Commit 5ea1ed7e authored by Chad Austin's avatar Chad Austin Committed by Facebook Github Bot

Add explicit operator=(None) to Optional

Summary:
In a minor way, this improves folly::Optional's compliance with std::optional. `op = folly::none` used to work by instantiating an empty optional and passing that in. This is more direct.

The existence of this assignment operator is why folly::None must not have a default constructor to support `op = {}` syntax for disengaging the optional.

Reviewed By: yfeldblum

Differential Revision: D12842963

fbshipit-source-id: 757bb66030a667ef0bc1cbe56d150740e712ed45
parent 2adb99bf
......@@ -204,6 +204,11 @@ class Optional {
}
}
Optional& operator=(None) noexcept {
reset();
return *this;
}
template <class Arg>
Optional& operator=(Arg&& arg) {
assign(std::forward<Arg>(arg));
......
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