37 #ifndef LARDATA_UTILITIES_TUPLELOOKUPBYTAG_H 38 #define LARDATA_UTILITIES_TUPLELOOKUPBYTAG_H 46 #include <type_traits> 75 template <
typename Target,
typename... T>
78 template <
typename Target,
typename... T>
84 template <
typename Tuple>
90 template <
typename Tagged,
typename =
void>
102 template <
typename Target,
typename... T>
106 template <
typename Target,
typename... T>
110 template <std::size_t N,
typename... T>
114 template <std::size_t N,
typename... T>
118 template <
typename Target,
typename... T>
122 template <
typename Target,
typename... T>
126 template <
typename Target,
typename Tuple>
181 template <
typename SrcTuple,
182 template <
typename T,
typename...>
184 template <
typename...>
class TargetClass = std::tuple>
188 template <
typename SrcTuple,
189 template <
typename T,
typename...>
191 template <
typename...>
class TargetClass = std::tuple>
197 template <
typename Tuple,
template <
typename...>
class TargetClass = std::tuple>
201 template <
typename Tuple,
template <
typename...>
class TargetClass = std::tuple>
234 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
238 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
245 template <
typename Target,
typename Tuple>
249 template <
typename Target,
typename Tuple>
282 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
284 std::tuple_element<index_of_extracted_type_v<Extractor, Target, Tuple>,
Tuple>;
287 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
336 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
340 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
345 template <
typename Target,
typename Tuple>
349 template <
typename Target,
typename Tuple>
389 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
416 template <
template <
typename T,
typename...>
class Extractor,
typename Tuple>
421 template <
template <
typename T,
typename...>
class Extractor,
typename Tuple>
428 template <
typename Tuple>
432 template <
typename Tuple>
464 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
468 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
475 template <
typename Target,
typename Tuple>
479 template <
typename Target,
typename Tuple>
531 template <
typename T,
typename Tag>
535 template <
typename... Args>
546 template <
typename T,
typename Tag>
553 template <
typename T,
typename Tag>
557 template <
typename Tagged>
562 template <
typename T,
typename Tag>
568 template <
typename Tagged>
582 template <
typename Tag,
typename T>
599 template <
typename Tag,
typename T>
617 template <
typename Tag,
typename T>
636 template <
typename Tag,
typename T>
643 template <
typename Tagged>
650 template <
typename Tagged>
657 template <
typename Tagged>
664 template <
typename Tagged>
671 template <std::size_t...>
682 template <
typename Tagged>
686 template <
typename Tagged>
690 template <
typename Tagged>
694 template <
typename SrcTuple>
698 template <
typename SrcTuple>
731 template <
typename Tag,
typename Tuple>
735 template <
typename Tag,
typename Tuple>
767 template <
typename Tag,
typename Tuple>
771 template <
typename Tag,
typename Tuple>
798 template <
typename Tag,
typename Tuple>
802 template <
typename Tag,
typename Tuple>
829 template <
typename Tag,
typename Tuple>
833 template <
typename Tag,
typename Tuple>
851 template <
typename Tuple>
855 template <
typename Tuple>
882 template <
typename Tag,
typename Tuple>
885 return getByExtractedType<TagExtractor, Tag>(data);
908 template <
typename Target,
typename... T>
909 struct count_type_in_list_impl :
public std::integral_constant<unsigned int, 0U> {};
911 template <
typename Target,
typename First,
typename... Others>
913 :
public std::integral_constant<unsigned int,
914 count_type_in_list_impl<Target, Others...>::value> {};
916 template <
typename Target,
typename... Others>
918 :
public std::integral_constant<unsigned int,
919 count_type_in_list_impl<Target, Others...>::value + 1> {};
932 template <
typename Target,
typename... T>
935 template <
typename Target,
typename First,
typename... Others>
937 :
public std::integral_constant<bool, type_is_in_impl<Target, Others...>::value> {};
939 template <
typename Target,
typename... Others>
961 template <
template <
typename...>
class TargetClass,
962 template <
typename T,
typename...>
976 typename Extractor<std::tuple_element_t<I, Tuple>>::
type>::
type;
980 template <
template <
typename...>
class TargetClass,
981 template <
typename T,
typename...>
987 using type = TargetClass<T...>;
993 template <
typename SrcTuple,
994 template <
typename T,
typename...>
996 template <
typename...>
1000 using type = TargetClass<typename Extractor<std::tuple_element_t<I, SrcTuple>>
::type...>;
1006 template <
template <
typename T,
typename...>
class Extractor,
1014 template <
template <
typename T,
typename...>
class Extractor,
1024 typename Extractor<std::tuple_element_t<I, Tuple>>::type,
1028 template <
template <
typename T,
typename...>
class Extractor,
1033 :
public std::integral_constant<std::size_t, N> {};
1034 template <
template <
typename T,
typename...>
class Extractor,
1042 std::tuple_size<Tuple>::value,
1047 template <
template <
typename T,
typename...>
class Extractor,
1052 :
public std::integral_constant<std::size_t, I> {
1053 static constexpr std::size_t N = std::tuple_size<Tuple>();
1054 static_assert(I < N,
"Internal logic error.");
1058 template <
template <
typename T,
typename...>
class Extractor,
1067 template <
template <
typename T,
typename...>
class Extractor,
1072 :
public std::integral_constant<std::size_t, N> {};
1077 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
1079 :
public std::integral_constant<std::size_t,
1080 index_of_extracted_type_checked<Extractor,
1082 std::tuple_size<Tuple>::value,
1087 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
1092 static_assert(value < N,
"The specified tuple does not have the sought type.");
1095 "The specified tuple has more than one element with the sought type.");
1100 template <
typename Tuple,
typename... T>
1103 template <
typename Tuple,
typename First,
typename... Others>
1105 :
public std::integral_constant<bool,
1106 (count_type_in_tuple<First, Tuple>::value > 1U) ||
1110 template <
typename... T>
1116 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename... Tags>
1120 template <
template <
typename T,
typename...>
class Extractor,
1122 typename... TagTuple>
1125 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename... Tags>
1132 template <
typename Tagged,
typename >
1137 template <
typename Tagged>
1140 std::enable_if_t<always_true_type<typename std::remove_reference_t<Tagged>::tag>::value>> {
1141 using type =
typename std::remove_reference_t<Tagged>::tag;
1153 template <
typename Target,
typename Tuple>
1156 "count_type_in_tuple requires an instance of std::tuple");
1160 template <
typename Target,
typename... T>
1166 template <
typename SrcTuple,
1167 template <
typename T,
typename...>
1169 template <
typename...>
1174 static constexpr std::size_t N = std::tuple_size<SrcTuple>();
1182 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
1184 :
public std::integral_constant<
1186 details::index_of_type_helper<Extractor, Target, Tuple>::value> {};
1189 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
1191 :
public std::integral_constant<bool,
1192 (details::index_of_type_base<Extractor, Target, Tuple>::value <
1193 std::tuple_size<Tuple>::value)> {};
1196 template <template <typename T, typename...> class Extractor, typename Target, typename Tuple>
1197 struct count_extracted_types
1198 : public count_type_in_tuple<Target, extract_to_tuple_type_t<Tuple, Extractor>> {};
1201 template <template <typename T, typename...> class Extractor, typename Target, typename Tuple>
1202 auto getByExtractedType(Tuple const& data) -> decltype(auto)
1205 return get<index_of_extracted_type_v<Extractor, Target, Tuple>>(data);
1217 #endif // LARDATA_UTILITIES_TUPLELOOKUPBYTAG_H TaggedType(Args &&...args)
Namespace for general, non-LArSoft-specific utilities.
A type with a specified tag.
Holds whether the Target type is element of the specified std::tuple.
Tag class parametrized by a sequence of numbers.
Tag tag
Tag of this object.
A std::false_type with a template argument.
Trait holding the type contained in a TaggedType (or the type itself).
T tagged_type
Type of the object which was tagged.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.