ATLAS Offline Software
MakeDerivedVariant.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MAKEDERIVEDVARIANT_H
6 #define MAKEDERIVEDVARIANT_H
7 
8 #include <variant>
9 
11 
12  template <typename T>
13  static T lvalue(T &&a) { return a;}
14 
15  // dummy method returning a variant which allows for one additional type than the given variant
16  template <class T, typename...Args>
17  constexpr std::variant<Args..., T> extend(const std::variant<Args...> &, const T &) {
18  return std::variant<Args..., T>();
19  }
20 
21  // helper structor to hold the declaration of the variant
22  template <typename TypeHelper,
23  typename VariantType,
24  std::size_t N = std::variant_size_v<VariantType> >
25  struct MakeVariant {
27  typename TypeHelper::template type<decltype( lvalue( std::get<N-1>(VariantType{})))> {} ) );
29  };
30 
31  // specialisation of above helper structure for N=1 i.e. the variant just allowing T<1>
32  template<typename TypeHelper,
33  typename VariantType>
34  struct MakeVariant<TypeHelper, VariantType, 1> {
35  using variant_type = std::variant< typename TypeHelper::template type< decltype( lvalue( std::get<0>(VariantType{}))) > > ;
37  };
38 
39 }
40 
41 #endif
ActsTrk::detail::MakeDerivedVariant::MakeVariant< TypeHelper, VariantType, 1 >::m_val
variant_type m_val
Definition: MakeDerivedVariant.h:36
ActsTrk::detail::MakeDerivedVariant::MakeVariant< TypeHelper, VariantType, 1 >::variant_type
std::variant< typename TypeHelper::template type< decltype(lvalue(std::get< 0 >(VariantType{}))) > > variant_type
Definition: MakeDerivedVariant.h:35
taskman.template
dictionary template
Definition: taskman.py:317
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
ActsTrk::detail::MakeDerivedVariant
Definition: MakeDerivedVariant.h:10
Args
Definition: test_lwtnn_fastgraph.cxx:12
ActsTrk::detail::MakeDerivedVariant::MakeVariant
Definition: MakeDerivedVariant.h:25
ActsTrk::detail::MakeDerivedVariant::MakeVariant::variant_type
decltype(extend(MakeVariant< TypeHelper, VariantType, N-1 >::m_val, typename TypeHelper::template type< decltype(lvalue(std::get< N-1 >(VariantType{})))> {})) variant_type
Definition: MakeDerivedVariant.h:27
ActsTrk::detail::MakeDerivedVariant::MakeVariant::m_val
variant_type m_val
Definition: MakeDerivedVariant.h:28
a
TList * a
Definition: liststreamerinfos.cxx:10
ActsTrk::detail::MakeDerivedVariant::extend
constexpr std::variant< Args..., T > extend(const std::variant< Args... > &, const T &)
Definition: MakeDerivedVariant.h:17
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78