50 template <
typename Visitor,
typename Variant>
52 template <
typename Visitor,
typename Variant>
54 template <
typename Visitor,
typename Variant>
59 template <
typename Visitor,
typename Variant,
typename T,
typename... Types>
63 [](
const Visitor& aVisitor, Variant& aThis)
65 typedef std::decay_t<T> type;
66 aVisitor(aThis.template get<type>());
78 template <
typename Id,
typename... Types>
82 template <
typename,
typename...>
100 return do_assign(aOther.which(), aOther.data());
108 auto& result = do_move_assign(aOther.which(), aOther.data());
115 template <
typename T>
116 std::enable_if_t<!std::is_base_of_v<self_type, T>, self_type>&
operator=(
const T& aArgument)
118 return do_assign(
static_cast<id_t>(variadic::index_v<T, Types...>), &aArgument);
120 template <
typename T>
121 std::enable_if_t<!std::is_base_of_v<self_type, std::remove_reference_t<T>>, self_type>&
operator=(T&& aArgument)
123 return do_move_assign(
static_cast<id_t>(variadic::no_reference_index_v<T, Types...>), &aArgument);
133 virtual bool operator<(
const self_type& that)
const = 0;
137 return std::partial_ordering::equivalent;
138 else if (*
this < that)
139 return std::partial_ordering::less;
141 return std::partial_ordering::greater;
156 template <
typename T>
159 if (
which() ==
static_cast<id_t>(variadic::index_v<T, Types...>))
160 return *
static_cast<const T*
>(data());
163 template <
typename T>
166 if (
which() ==
static_cast<id_t>(variadic::index_v<T, Types...>))
167 return *
static_cast<T*
>(data());
175 virtual std::size_t index()
const = 0;
176 virtual const void* data()
const = 0;
177 virtual void* data() = 0;
178 virtual self_type* do_clone()
const = 0;
179 virtual self_type& do_assign(
id_t aType,
const void* aData) = 0;
180 virtual self_type& do_move_assign(
id_t aType,
void* aData) = 0;
183 namespace variant_visitors
185 template <
typename Visitor,
typename Id,
typename... Types>
191 auto const which = aVariant.
which();
192 auto const index =
static_cast<std::size_t
>(which);
194 funks[index](aVisitor, aVariant);
196 throw std::bad_variant_access();
199 template <
typename Visitor,
typename Id,
typename... Types>
205 auto const which = aVariant.
which();
206 auto const index =
static_cast<std::size_t
>(which);
208 funks[index](aVisitor, aVariant);
210 throw std::bad_variant_access();
214 template <
typename T,
typename Id,
typename... Types>
218 variant_visitors::visit([&result](
auto&& v)
220 if constexpr (std::is_convertible_v<
decltype(v), T>)
221 result =
static_cast<T
>(v);
231 using neolib::variant_visitors::visit;
self_type & operator=(const none_t)
virtual bool empty() const =0
virtual const i_enum_t< Id >::enumerators_t & ids() const =0
std::enable_if_t<!std::is_base_of_v< self_type, std::remove_reference_t< T > >, self_type > & operator=(T &&aArgument)
ref_ptr< self_type > clone() const
std::enable_if_t<!std::is_base_of_v< self_type, T >, self_type > & operator=(const T &aArgument)
std::partial_ordering operator<=>(const self_type &that) const
bool operator==(const none_t) const
self_type & operator=(const self_type &aOther)
virtual bool operator<(const self_type &that) const =0
virtual bool operator==(const self_type &that) const =0
virtual id_t which() const =0
self_type & operator=(self_type &&aOther)
bool operator!=(const none_t) const
friend class plugin_variant
std::function< void(const Visitor &, Variant &)> funky_visit_t
std::vector< funky_visit_t< Visitor, Variant > > funky_visit_list_t
std::size_t funky_gen_visit(funky_visit_list_t< Visitor, Variant > &aList)
T get_as(const i_plugin_variant< Id, Types... > &aVariant)
i_basic_enum< std::underlying_type_t< T > > i_enum_t
variant_type_not_convertible()
variant_type_not_equality_comparable()
variant_type_not_less_than_comparable()