diff --git a/include/continuable/detail/variant.hpp b/include/continuable/detail/flat-variant.hpp similarity index 69% rename from include/continuable/detail/variant.hpp rename to include/continuable/detail/flat-variant.hpp index 6a33136..765a720 100644 --- a/include/continuable/detail/variant.hpp +++ b/include/continuable/detail/flat-variant.hpp @@ -28,8 +28,8 @@ SOFTWARE. **/ -#ifndef CONTINUABLE_DETAIL_VARIANT_HPP_INCLUDED -#define CONTINUABLE_DETAIL_VARIANT_HPP_INCLUDED +#ifndef CONTINUABLE_DETAIL_FLAT_VARIANT_HPP_INCLUDED +#define CONTINUABLE_DETAIL_FLAT_VARIANT_HPP_INCLUDED #include #include @@ -42,7 +42,7 @@ namespace cti { namespace detail { -namespace variant { +namespace container { namespace detail { // We don't want to pull the algorithm header in template @@ -74,31 +74,31 @@ using empty_slot = std::integral_constant::max()>; template -struct optional_variant_base { +struct flat_variant_base { storage_of_t storage_; slot_t slot_; - constexpr optional_variant_base() : slot_(empty_slot::value) { + constexpr flat_variant_base() : slot_(empty_slot::value) { } - optional_variant_base(optional_variant_base const&) noexcept { + flat_variant_base(flat_variant_base const&) noexcept { } - optional_variant_base(optional_variant_base&&) noexcept { + flat_variant_base(flat_variant_base&&) noexcept { } - optional_variant_base& operator=(optional_variant_base const&) { + flat_variant_base& operator=(flat_variant_base const&) { return *this; } - optional_variant_base& operator=(optional_variant_base&&) { + flat_variant_base& operator=(flat_variant_base&&) { return *this; } }; template -struct optional_variant_move_base { - constexpr optional_variant_move_base() = default; +struct flat_variant_move_base { + constexpr flat_variant_move_base() = default; - optional_variant_move_base(optional_variant_move_base const&) = default; - explicit optional_variant_move_base(optional_variant_move_base&& right) { + flat_variant_move_base(flat_variant_move_base const&) = default; + explicit flat_variant_move_base(flat_variant_move_base&& right) { Base& me = *static_cast(this); Base& other = *static_cast(&right); assert(!other.is_empty()); @@ -114,9 +114,8 @@ struct optional_variant_move_base { me.set_slot(other.get()); other.destroy(); } - optional_variant_move_base& - operator=(optional_variant_move_base const&) = default; - optional_variant_move_base& operator=(optional_variant_move_base&& right) { + flat_variant_move_base& operator=(flat_variant_move_base const&) = default; + flat_variant_move_base& operator=(flat_variant_move_base&& right) { Base& me = *static_cast(this); Base& other = *static_cast(&right); assert(!other.is_empty()); @@ -133,12 +132,12 @@ struct optional_variant_move_base { } }; template -struct optional_variant_copy_base : optional_variant_move_base { - constexpr optional_variant_copy_base() = default; +struct flat_variant_copy_base : flat_variant_move_base { + constexpr flat_variant_copy_base() = default; - optional_variant_copy_base(optional_variant_copy_base&&) = default; - explicit optional_variant_copy_base(optional_variant_copy_base const& right) - : optional_variant_copy_base() + flat_variant_copy_base(flat_variant_copy_base&&) = default; + explicit flat_variant_copy_base(flat_variant_copy_base const& right) + : flat_variant_copy_base() // TODO noexcept(Base::is_nothrow_move_constructible) { Base& me = *static_cast(this); @@ -155,8 +154,8 @@ struct optional_variant_copy_base : optional_variant_move_base { }); me.set_slot(other.get()); } - optional_variant_copy_base& operator=(optional_variant_copy_base&&) = default; - optional_variant_copy_base& operator=(optional_variant_copy_base const& right) + flat_variant_copy_base& operator=(flat_variant_copy_base&&) = default; + flat_variant_copy_base& operator=(flat_variant_copy_base const& right) // TODO noexcept(Base::is_nothrow_move_constructible) { Base& me = *static_cast(this); @@ -174,16 +173,13 @@ struct optional_variant_copy_base : optional_variant_move_base { } }; template -struct optional_variant_copy_base - : optional_variant_move_base { - constexpr optional_variant_copy_base() = default; +struct flat_variant_copy_base : flat_variant_move_base { + constexpr flat_variant_copy_base() = default; - optional_variant_copy_base(optional_variant_copy_base const&) = delete; - explicit optional_variant_copy_base(optional_variant_copy_base&& right) = - default; - optional_variant_copy_base& - operator=(optional_variant_copy_base const&) = delete; - optional_variant_copy_base& operator=(optional_variant_copy_base&&) = default; + flat_variant_copy_base(flat_variant_copy_base const&) = delete; + explicit flat_variant_copy_base(flat_variant_copy_base&& right) = default; + flat_variant_copy_base& operator=(flat_variant_copy_base const&) = delete; + flat_variant_copy_base& operator=(flat_variant_copy_base&&) = default; }; /// Deduces to a true_type if all parameters T satisfy the predicate. @@ -191,54 +187,53 @@ template