37 #ifndef LARDATA_UTILITIES_TUPLELOOKUPBYTAG_H 38 #define LARDATA_UTILITIES_TUPLELOOKUPBYTAG_H 45 #include <type_traits> 75 template <
typename Target,
typename...
T>
78 template <
typename Target,
typename...
T>
85 template <
typename Tuple>
92 template <
typename Tagged,
typename =
void>
106 template <
typename Target,
typename...
T>
110 template <
typename Target,
typename...
T>
115 template <std::size_t
N,
typename...
T>
119 template <std::size_t
N,
typename...
T>
124 template <
typename Target,
typename...
T>
128 template <
typename Target,
typename...
T>
133 template <
typename Target,
typename Tuple>
192 template <
typename T,
typename...>
class Extractor,
193 template <
typename...>
class TargetClass = std::tuple
201 template <
typename T,
typename...>
class Extractor,
202 template <
typename...>
class TargetClass = std::tuple
211 <
typename Tuple,
template <
typename...>
class TargetClass = std::tuple>
216 <
typename Tuple,
template <
typename...>
class TargetClass = std::tuple>
251 template <
typename T,
typename...>
class Extractor,
259 template <
typename T,
typename...>
class Extractor,
270 template <
typename Target,
typename Tuple>
275 template <
typename Target,
typename Tuple>
310 template <
typename T,
typename...>
class Extractor,
315 <index_of_extracted_type_v<Extractor, Target, Tuple>,
Tuple>;
319 template <
typename T,
typename...>
class Extractor,
373 template <
typename T,
typename...>
class Extractor,
381 template <
typename T,
typename...>
class Extractor,
391 template <
typename Target,
typename Tuple>
395 template<
typename Target,
typename Tuple>
437 template <
typename T,
typename...>
class Extractor,
467 template <
template <
typename T,
typename...>
class Extractor,
typename Tuple>
470 <extract_to_tuple_type_t<Tuple, Extractor>>
474 template <
template <
typename T,
typename...>
class Extractor,
typename Tuple>
482 template <
typename Tuple>
486 template <
typename Tuple>
520 template <
typename T,
typename...>
class Extractor,
528 template <
typename T,
typename...>
class Extractor,
539 template <
typename Target,
typename Tuple>
543 template <
typename Target,
typename Tuple>
596 template <
typename T,
typename Tag>
600 template <
typename... Args>
611 template <
typename T,
typename Tag>
616 template <
typename T,
typename Tag>
621 template <
typename Tagged>
624 template <
typename T,
typename Tag>
629 template <
typename Tagged>
644 template <
typename Tag,
typename T>
659 template <
typename Tag,
typename T>
675 template <
typename Tag,
typename T>
692 template <
typename Tag,
typename T>
697 template <
typename Tagged>
702 template <
typename Tagged>
707 template <
typename Tagged>
712 template <
typename Tagged>
718 template <std::size_t...>
730 template <
typename Tagged>
734 template <
typename Tagged>
738 template <
typename Tagged>
743 template <
typename SrcTuple>
747 template <
typename SrcTuple>
781 template <
typename Tag,
typename Tuple>
786 template <
typename Tag,
typename Tuple>
819 template <
typename Tag,
typename Tuple>
824 template <
typename Tag,
typename Tuple>
852 template <
typename Tag,
typename Tuple>
856 template <
typename Tag,
typename Tuple>
884 template <
typename Tag,
typename Tuple>
888 template <
typename Tag,
typename Tuple>
907 template <
typename Tuple>
911 template <
typename Tuple>
939 template <
typename Tag,
typename Tuple>
941 {
return getByExtractedType<TagExtractor, Tag>(
data); }
965 template <
typename Target,
typename...
T>
966 struct count_type_in_list_impl:
public std::integral_constant<unsigned int, 0U>
969 template <
typename Target,
typename First,
typename... Others>
971 :
public std::integral_constant
972 <unsigned int, count_type_in_list_impl<Target, Others...>::value>
975 template <
typename Target,
typename... Others>
977 :
public std::integral_constant
978 <unsigned int, count_type_in_list_impl<Target, Others...>::value + 1>
995 template <
typename Target,
typename...
T>
998 template <
typename Target,
typename First,
typename... Others>
1000 :
public std::integral_constant<bool, type_is_in_impl<Target, Others...>::value>
1003 template <
typename Target,
typename... Others>
1026 template <
template <
typename...>
class TargetClass,
template <
typename T,
typename...>
class Extractor,
typename Tuple, std::size_t
I, std::size_t
N,
typename... T>
1032 template <
template <
typename...>
class TargetClass,
template <
typename T,
typename...>
class Extractor,
typename Tuple, std::size_t
N,
typename... T>
1041 template <
typename SrcTuple,
template <
typename T,
typename...>
class Extractor,
template <
typename...>
class TargetClass, std::size_t... I>
1043 using type = TargetClass<
1044 typename Extractor<std::tuple_element_t<I, SrcTuple>>
::type...
1052 template <
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
I,
typename Elem,
typename Tuple>
1056 template <
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
N, std::size_t
I,
typename Tuple>
1062 template<
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
N,
typename Tuple>
1064 :
public std::integral_constant<std::size_t, N>
1066 template <
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
I,
typename Elem,
typename Tuple>
1069 <Extractor, Target, std::tuple_size<Tuple>::value, (I + 1), Tuple>
1073 template <
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
I,
typename Tuple>
1075 :
public std::integral_constant<std::size_t, I>
1077 static constexpr std::size_t N = std::tuple_size<Tuple>();
1078 static_assert(I < N,
"Internal logic error.");
1082 template <
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
N, std::size_t After,
typename Tuple>
1088 template <
template <
typename T,
typename...>
class Extractor,
typename Target, std::size_t
N,
typename Tuple>
1090 :
public std::integral_constant<std::size_t, N>
1097 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
1099 :
public std::integral_constant<
1101 index_of_extracted_type_checked<Extractor, Target, std::tuple_size<Tuple>::value, 0U, Tuple>::value
1106 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename Tuple>
1111 static_assert(value < N,
1112 "The specified tuple does not have the sought type.");
1114 "The specified tuple has more than one element with the sought type.");
1120 template <
typename Tuple,
typename... T>
1123 template <
typename Tuple,
typename First,
typename... Others>
1125 :
public std::integral_constant<bool,
1126 (count_type_in_tuple<First, Tuple>::value > 1U)
1133 template <
typename... T>
1141 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename... Tags>
1146 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename... TagTuple>
1149 template <
template <
typename T,
typename...>
class Extractor,
typename Target,
typename... Tags>
1158 template <
typename Tagged,
typename >
1163 template <
typename Tagged>
1167 <always_true_type<typename std::remove_reference_t<Tagged>::tag>::value>
1170 using type =
typename std::remove_reference_t<Tagged>::tag;
1184 template <
typename Target,
typename Tuple>
1188 "count_type_in_tuple requires an instance of std::tuple");
1192 template <
typename Target,
typename... T>
1203 template <
typename T,
typename...>
class Extractor,
1204 template <
typename...>
class TargetClass
1208 static constexpr std::size_t N = std::tuple_size<SrcTuple>();
1211 <TargetClass, Extractor, SrcTuple, 0U, N>
::type;
1217 template <
typename T,
typename...>
class Extractor,
1222 :
public std::integral_constant<
1224 details::index_of_type_helper<Extractor, Target, Tuple>::value
1231 template <
typename T,
typename...>
class Extractor,
1236 :
public std::integral_constant<
1238 (details::index_of_type_base<Extractor, Target, Tuple>::value < std::tuple_size<Tuple>::value)
1245 template <typename T, typename...> class Extractor,
1249 struct count_extracted_types
1250 : public count_type_in_tuple
1251 <Target, extract_to_tuple_type_t<Tuple, Extractor>>
1257 template <typename T, typename...> class Extractor,
1260 auto getByExtractedType(Tuple const& data) -> decltype(auto)
1263 return get<index_of_extracted_type_v<Extractor, Target, Tuple>>(
data);
1278 #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.
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.
auto const & get(AssnsNode< L, R, D > const &r)