7 template <
typename BaseVariantTraitsType,
bool IsConst,
typename TupleType,
size_t Index>
10 using RetType =
typename BaseVariantTraitsType::ReferenceVariant;
11 using BaseType =
typename BaseVariantTraitsType::BaseType;
14 template <
typename BaseVariantTraitsType,
bool IsConst,
typename... DerivedTypes,
size_t Index>
17 using BaseType_ =
typename BaseVariantTraitsType::BaseType;
18 using BaseType = std::conditional_t<IsConst, const BaseType_, BaseType_>;
20 using TupleType =
typename BaseVariantTraitsType::DerivedTypesTuple;
22 using RetType =
typename BaseVariantTraitsType::template ReferenceVariant_const<IsConst>;
24 using RefTupleType =
typename BaseVariantTraitsType::template ReferenceTuple_const<IsConst>;
26 using MyRefType = std::tuple_element_t<Index, RefTupleType>;
34 if constexpr (Index <
sizeof...(DerivedTypes)) {
37 std::in_place_type_t<MyRefType>{},
38 static_cast<std::conditional_t<IsConst, const MyDerivedType, MyDerivedType>&
>(
41 if constexpr (Index + 1 <
sizeof...(DerivedTypes)) {
47 throw std::runtime_error(
"Invalid Input");
50 std::in_place_type_t<FirstRefType>{},
52 std::conditional_t<IsConst, const FirstDerivedType, FirstDerivedType>&
>(value));
57 template <
typename BaseVariantTraitsType>
58 typename BaseVariantTraitsType::ReferenceVariant
as_variant(
59 typename BaseVariantTraitsType::BaseType& value)
62 BaseVariantTraitsType,
64 typename BaseVariantTraitsType::DerivedTypesTuple,
66 return impl::exec(value, BaseVariantTraitsType::get_index(value));
69 template <
typename BaseVariantTraitsType>
71 const typename BaseVariantTraitsType::BaseType& value)
74 BaseVariantTraitsType,
76 typename BaseVariantTraitsType::DerivedTypesTuple,
78 return impl::exec(value, BaseVariantTraitsType::get_index(value));