util: Implement Expected::operator*()&&
It is currently unused, but implementing it is closer to std::expected.
This commit is contained in:
2 files changed
+10
-2
No files matched your search
@@ -50,6 +50,13 @@ BOOST_AUTO_TEST_CASE(expected_value_rvalue)
|
|||||||
BOOST_CHECK_EQUAL(*moved, 5);
|
BOOST_CHECK_EQUAL(*moved, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(expected_deref_rvalue)
|
||||||
|
{
|
||||||
|
Expected<std::unique_ptr<int>, int> no_copy{std::make_unique<int>(5)};
|
||||||
|
const auto moved{*std::move(no_copy)};
|
||||||
|
BOOST_CHECK_EQUAL(*moved, 5);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(expected_value_or)
|
BOOST_AUTO_TEST_CASE(expected_value_or)
|
||||||
{
|
{
|
||||||
Expected<std::unique_ptr<int>, int> no_copy{std::make_unique<int>(1)};
|
Expected<std::unique_ptr<int>, int> no_copy{std::make_unique<int>(1)};
|
||||||
|
|||||||
+3
-2
@@ -88,8 +88,9 @@ public:
|
|||||||
constexpr E& error() & noexcept LIFETIMEBOUND { return *Assert(std::get_if<1>(&m_data)); }
|
constexpr E& error() & noexcept LIFETIMEBOUND { return *Assert(std::get_if<1>(&m_data)); }
|
||||||
constexpr E&& error() && noexcept LIFETIMEBOUND { return std::move(error()); }
|
constexpr E&& error() && noexcept LIFETIMEBOUND { return std::move(error()); }
|
||||||
|
|
||||||
constexpr T& operator*() noexcept LIFETIMEBOUND { return value(); }
|
constexpr T& operator*() & noexcept LIFETIMEBOUND { return value(); }
|
||||||
constexpr const T& operator*() const noexcept LIFETIMEBOUND { return value(); }
|
constexpr const T& operator*() const& noexcept LIFETIMEBOUND { return value(); }
|
||||||
|
constexpr T&& operator*() && noexcept LIFETIMEBOUND { return std::move(value()); }
|
||||||
|
|
||||||
constexpr T* operator->() noexcept LIFETIMEBOUND { return &value(); }
|
constexpr T* operator->() noexcept LIFETIMEBOUND { return &value(); }
|
||||||
constexpr const T* operator->() const noexcept LIFETIMEBOUND { return &value(); }
|
constexpr const T* operator->() const noexcept LIFETIMEBOUND { return &value(); }
|
||||||
|
|||||||
Reference in new issue
Block a user