Clean up converting constructors

This commit is contained in:
Simon Brand
2018-06-08 12:42:00 +01:00
parent 259def9a8a
commit 4492830414

View File

@@ -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,11 +1502,9 @@ 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;
} }
} }
@@ -1520,11 +1516,9 @@ 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;
} }
} }
@@ -1537,11 +1531,9 @@ 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;
} }
} }