mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-28 02:48:09 +08:00
Support rvalue reference overload for Optional::get
This commit is contained in:
parent
ef50452bfb
commit
8191a38b88
@ -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…
x
Reference in New Issue
Block a user