13 #ifndef DETECTORINFO_PROVIDERPACK_H 14 #define DETECTORINFO_PROVIDERPACK_H 19 #include <type_traits> 27 template <
typename... Types>
31 template <
typename Key,
typename... Types>
54 template <
typename FindType,
typename... AmongTypes>
59 template <
typename DestPack,
typename SourcePack,
typename... ExtractProviders>
89 template <
typename... Providers>
92 "Providers in ProviderPack are repeated");
104 ProviderPack(Providers
const* ...provider_ptrs): providers(provider_ptrs...)
115 template<
typename... OtherProviders>
131 template<
typename... OtherProviders>
136 (*
this,
ProviderPack<OtherProviders...>(providers_tmp...));
140 template <
typename Prov
ider>
141 Provider
const*
get()
const 149 template <
typename Prov
ider>
150 void set(Provider
const* provider_ptr)
158 template <
typename Prov
ider>
159 static constexpr
bool has()
162 <
sizeof...(Providers);
181 template <
typename... Providers>
198 template <
typename Key,
typename... Types>
200 public std::integral_constant<
202 index_with_type_impl<Key, Types...>::value < sizeof...(Types)
203 || has_duplicate_types<Types...>::value
208 struct has_duplicate_types<>: public std::false_type {};
218 template <typename Key, typename... Types>
219 struct index_with_type_impl;
222 template <typename Key, typename FirstType, typename... Types>
223 struct index_with_type_impl<Key, FirstType, Types...>:
224 public std::integral_constant <size_t,
225 std::is_same<Key, FirstType>::value
227 : index_with_type_impl<Key, Types...>::value + 1
232 template <typename Key>
233 struct index_with_type_impl<Key>: public std::integral_constant <size_t, 0U>
237 template <typename FindType, typename... AmongTypes>
238 struct index_with_type:
239 public std::integral_constant
240 <size_t, index_with_type_impl<FindType, AmongTypes...>::value>
243 index_with_type<FindType, AmongTypes...>::value < sizeof...(AmongTypes),
244 "Required type is not present"
252 typename DestPack, typename SourcePack,
253 typename FirstProvider, typename... OtherProviders
255 struct SetFrom<DestPack, SourcePack, FirstProvider, OtherProviders...> {
256 SetFrom(DestPack& pack, SourcePack const& from)
258 pack.set(from.template get<FirstProvider>());
259 SetFrom<DestPack, SourcePack, OtherProviders...>(pack, from);
263 template <typename DestPack, typename SourcePack>
264 struct SetFrom<DestPack, SourcePack> {
265 SetFrom(DestPack&, SourcePack const&) {}
ProviderPack(OtherProviders const *...providers_tmp)
Constructor: extracts the providers from anothe parameter pack.
Implementation detail for the extraction constructor.
Container for a list of pointers to providers.
ProviderPack(ProviderPack< OtherProviders... > const &from)
Constructor: extracts the providers from anothe parameter pack.
std::tuple< Providers const *... > tuple_type
type used for storage of the pointers
static constexpr bool has()
Returns whether there is a provider with the specified type.
General GArSoft Utilities.
Hosts the index of type FindType in the list of types AmongTypes.
auto const & get(AssnsNode< L, R, D > const &r)
ProviderPack< Providers... > makeProviderPack(Providers const *...providers)
Function to create a ParameterPack from the function arguments.
tuple_type providers
container of the pointers, type-safe
ProviderPack(Providers const *...provider_ptrs)
Constructor: stores a provider pointer for each type.