Merge pull request #3962 from sfc-gh-tclinkenbeard/add-optional-get-overload
Support rvalue reference overload for Optional::get
This commit is contained in:
commit
1fe775d393
|
@ -242,14 +242,18 @@ public:
|
|||
}
|
||||
|
||||
bool present() const { return impl.has_value(); }
|
||||
T& get() {
|
||||
T& get() & {
|
||||
UNSTOPPABLE_ASSERT(impl.has_value());
|
||||
return impl.value();
|
||||
}
|
||||
T const& get() const {
|
||||
T const& get() const& {
|
||||
UNSTOPPABLE_ASSERT(impl.has_value());
|
||||
return impl.value();
|
||||
}
|
||||
T&& get() && {
|
||||
UNSTOPPABLE_ASSERT(impl.has_value());
|
||||
return std::move(impl.value());
|
||||
}
|
||||
T orDefault(T const& default_value) const { return impl.value_or(default_value); }
|
||||
|
||||
// Spaceship operator. Treats not-present as less-than present.
|
||||
|
|
Loading…
Reference in New Issue