ATLAS Offline Software
Loading...
Searching...
No Matches
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
static Double_t a
constexpr std::variant< Args..., T > extend(const std::variant< Args... > &, const T &)
std::variant< typename TypeHelper::template type< decltype(lvalue(std::get< 0 >(VariantType{}))) > > variant_type
decltype(extend(MakeVariant< CalibratorType, measurement_container_variant_t, std::variant_size_v< measurement_container_variant_t > -1 >::m_val, typename CalibratorType::template type< decltype(lvalue(std::get< std::variant_size_v< measurement_container_variant_t > -1 >(measurement_container_variant_t{})))> {})) variant_type