This commit is contained in:
Sebastian Messmer 2018-12-24 18:52:48 +01:00
parent 57fc1f1cb8
commit 1b2aaf5da4
1 changed files with 16 additions and 2 deletions

View File

@ -115,7 +115,14 @@ namespace cpputils {
return boost::none;
}
}
// left_opt()&& not offered because optional<Left&&> doesn't work
// warning: opposed to the other left_opt variants, this one already moves the content and returns by value.
boost::optional<Left> left_opt() && noexcept(noexcept(boost::optional<Left>(std::move(_left)))) {
if (_side == Side::left) {
return std::move(_left);
} else {
return boost::none;
}
}
boost::optional<const Right&> right_opt() const& noexcept {
if (_side == Side::right) {
@ -131,7 +138,14 @@ namespace cpputils {
return boost::none;
}
}
// right_opt()&& not offered because optional<Right&&> doesn't work
// warning: opposed to the other left_opt variants, this one already moves the content and returns by value.
boost::optional<Right> right_opt() && noexcept(noexcept(boost::optional<Right>(std::move(_right)))) {
if (_side == Side::right) {
return std::move(_right);
} else {
return boost::none;
}
}
private:
union {