diff --git a/include/continuable/detail/expected.hpp b/include/continuable/detail/expected.hpp index 1285e2d..1a44b1a 100644 --- a/include/continuable/detail/expected.hpp +++ b/include/continuable/detail/expected.hpp @@ -52,6 +52,26 @@ using storage_of_t = // ? sizeof(types::error_type) : sizeof(T))>; +template +struct expected_base { + storage_of_t storage_; + slot_t slot_; + + constexpr expected_base() : slot_(slot_t::empty) { + } + + expected_base(expected_base const&) noexcept { + } + expected_base(expected_base&&) noexcept { + } + expected_base& operator=(expected_base const&) { + return *this; + } + expected_base& operator=(expected_base&&) { + return *this; + } +}; + template struct expected_move_base { constexpr expected_move_base() = default; @@ -148,7 +168,8 @@ template class expected : detail::expected_copy_base< expected, std::is_copy_constructible::value && - std::is_copy_constructible::value> { + std::is_copy_constructible::value>, + detail::expected_base { template friend class expected; @@ -157,9 +178,6 @@ class expected template friend struct detail::expected_copy_base; - detail::storage_of_t storage_; - detail::slot_t slot_; - template expected(V&& value, detail::slot_t const slot) { using type = std::decay_t; @@ -168,9 +186,7 @@ class expected } public: - constexpr expected() : slot_(detail::slot_t::empty) { - } - + constexpr expected() = default; expected(expected const&) = default; expected(expected&&) = default; expected& operator=(expected const&) = default;