mirror of
https://github.com/TartanLlama/expected.git
synced 2025-08-03 02:44:30 +02:00
Clean up converting constructors
This commit is contained in:
@@ -1486,11 +1486,9 @@ public:
|
|||||||
explicit TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G> &rhs)
|
explicit TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G> &rhs)
|
||||||
: ctor_base(detail::default_constructor_tag{}) {
|
: ctor_base(detail::default_constructor_tag{}) {
|
||||||
if (rhs.has_value()) {
|
if (rhs.has_value()) {
|
||||||
::new (valptr()) T(*rhs);
|
this->construct(*rhs);
|
||||||
this->m_has_val = true;
|
|
||||||
} else {
|
} else {
|
||||||
::new (errptr()) unexpected_type(unexpected<E>(rhs.error()));
|
this->construct_error(rhs.error());
|
||||||
this->m_has_val = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1504,12 +1502,10 @@ public:
|
|||||||
TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G> &rhs)
|
TL_EXPECTED_11_CONSTEXPR expected(const expected<U, G> &rhs)
|
||||||
: ctor_base(detail::default_constructor_tag{}) {
|
: ctor_base(detail::default_constructor_tag{}) {
|
||||||
if (rhs.has_value()) {
|
if (rhs.has_value()) {
|
||||||
::new (valptr()) T(*rhs);
|
this->construct(*rhs);
|
||||||
this->m_has_val = true;
|
|
||||||
} else {
|
} else {
|
||||||
::new (errptr()) unexpected_type(unexpected<E>(rhs.error()));
|
this->construct_error(rhs.error());
|
||||||
this->m_has_val = false;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
@@ -1520,12 +1516,10 @@ public:
|
|||||||
explicit TL_EXPECTED_11_CONSTEXPR expected(expected<U, G> &&rhs)
|
explicit TL_EXPECTED_11_CONSTEXPR expected(expected<U, G> &&rhs)
|
||||||
: ctor_base(detail::default_constructor_tag{}) {
|
: ctor_base(detail::default_constructor_tag{}) {
|
||||||
if (rhs.has_value()) {
|
if (rhs.has_value()) {
|
||||||
::new (valptr()) T(std::move(*rhs));
|
this->construct(std::move(*rhs));
|
||||||
this->m_has_val = true;
|
|
||||||
} else {
|
} else {
|
||||||
::new (errptr()) unexpected_type(unexpected<E>(std::move(rhs.error())));
|
this->construct_error(std::move(rhs.error()));
|
||||||
this->m_has_val = false;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \exclude
|
/// \exclude
|
||||||
@@ -1537,12 +1531,10 @@ public:
|
|||||||
TL_EXPECTED_11_CONSTEXPR expected(expected<U, G> &&rhs)
|
TL_EXPECTED_11_CONSTEXPR expected(expected<U, G> &&rhs)
|
||||||
: ctor_base(detail::default_constructor_tag{}) {
|
: ctor_base(detail::default_constructor_tag{}) {
|
||||||
if (rhs.has_value()) {
|
if (rhs.has_value()) {
|
||||||
::new (valptr()) T(std::move(*rhs));
|
this->construct(std::move(*rhs));
|
||||||
this->m_has_val = true;
|
|
||||||
} else {
|
} else {
|
||||||
::new (errptr()) unexpected_type(unexpected<E>(std::move(rhs.error())));
|
this->construct_error(std::move(rhs.error()));
|
||||||
this->m_has_val = false;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
|
Reference in New Issue
Block a user