11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXYELEMENT_H 12 #define LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXYELEMENT_H 23 #include <type_traits> 33 template <
typename AuxCollTuple>
161 template <
typename CollProxy>
170 <
typename collection_proxy_t::aux_collections_t>
::type;
176 : fIndex(index), fMain(&main) , fAuxData(
std::move(auxData))
186 std::size_t
index()
const {
return fIndex; };
189 template <
typename Tag>
190 auto get()
const -> decltype(
auto)
191 {
return std::get<util::index_of_tag_v<Tag, aux_elements_t>>(fAuxData); }
264 template <
typename Tag,
typename T = Tag const&>
265 [[deprecated(
"Use C++17 constexpr if instead and get() instead")]]
266 auto getIf()
const -> decltype(
auto);
270 template <
typename Tag>
271 static constexpr
bool has() {
return util::has_tag_v<Tag, aux_elements_t>; }
282 template <
typename Tag,
typename>
283 auto getIfHas(std::bool_constant<true>)
const -> decltype(auto);
285 template <typename
Tag, typename
T>
310 template <
typename ProxyElement,
typename... AuxData>
313 typename ProxyElement::main_element_t
const& main,
318 typename ProxyElement::aux_elements_t(std::forward<AuxData>(auxData)...)
342 template <
typename Tuple>
348 template <
typename...
T>
350 using type = std::tuple<
typename T::auxiliary_data_t...>;
361 template <
typename CollProxy>
362 template <
typename Tag,
typename T>
364 {
return getIfHas<Tag, T>(std::bool_constant<has<Tag>()>{}); }
368 template <
typename CollProxy>
369 template <
typename Tag,
typename>
371 (std::bool_constant<true>)
const -> decltype(
auto)
372 {
return get<Tag>(); }
374 template <
typename CollProxy>
375 template <
typename Tag,
typename T>
377 (std::bool_constant<false>)
const ->
T 379 throw std::logic_error
380 (
"Tag '" + lar::debug::demangle<Tag>() +
"' not available.");
389 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_COLLECTIONPROXYELEMENT_H main_element_t const * operator->() const
Returns a pointer to the main element.
auto makeCollectionProxyElement(std::size_t index, typename ProxyElement::main_element_t const &main, AuxData &&...auxData)
Creates a collection proxy element object from data structures.
typename collection_proxy_t::main_element_t main_element_t
Functions to help debugging by instrumenting code.
std::integral_constant< bool, Value > bool_constant
auto getIfHas(std::bool_constant< true >) const -> decltype(auto)
aux_elements_t fAuxData
Data associated to the main object.
static constexpr bool has()
Returns whether this class knowns about the specified type (Tag).
main_element_t const * fMain
Pointer to the main object of the element.
CollProxy collection_proxy_t
std::size_t index() const
Returns the index of this element in the collection.
std::size_t fIndex
Index of this element in the proxy.
A std::true_type with a template argument.
An element of a collection proxy.
typename details::SubstituteWithAuxList< typename collection_proxy_t::aux_collections_t >::type aux_elements_t
Tuple of elements (expected to be tagged types).
Utilities to address elements of a tuple-like class by tag.
auto getIf() const -> decltype(auto)
Returns the auxiliary data specified by type (Tag).
main_element_t const & operator*() const
Returns a reference to the main element.