Belle II Software development
EvalVariadic.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tuple>
11#include <type_traits>
12
13namespace Belle2 {
18 namespace TrackFindingCDC {
19
27 template <class... Ts>
28 static inline void evalVariadic(Ts&& ... expressions __attribute__((unused)))
29 {
30 }
31
37 struct EvalVariadic {
39 template <class... Ts>
40 explicit EvalVariadic(Ts&& ... expressions __attribute__((unused)))
41 {
42 }
43 };
44
45
47 template<class... ATypes>
49 };
50
52 template<>
53 struct FirstTypeImpl<> {
54 };
55
57 template<class AType>
58 struct FirstTypeImpl<AType> {
60 using Type = AType;
61 };
62
64 template<class AType, class... ATypes>
65 struct FirstTypeImpl<AType, ATypes...> {
67 using Type = AType;
68 };
69
71 template<class... ATypes>
72 using FirstType = typename FirstTypeImpl<ATypes...>::Type;
73
77 template<class AType, class ATuple>
78 struct GetIndexInTuple {};
79
81 template<class AType>
82 struct GetIndexInTuple<AType, std::tuple<> > :
83 std::integral_constant<std::size_t, 0> {};
84
86 template<class AType, class AHeadType, class... ATailTypes>
87 struct GetIndexInTuple<AType, std::tuple<AHeadType, ATailTypes...> > :
88 std::integral_constant < std::size_t, GetIndexInTuple<AType, std::tuple<ATailTypes...> >::value + 1 > {};
89
91 template<class AType, class... ATailTypes>
92 struct GetIndexInTuple <AType, std::tuple<AType, ATailTypes...> > :
93 std::integral_constant< std::size_t, 0> {};
94
96 template<class T, class ATuple>
97 using TypeInTuple =
98 std::integral_constant < bool, (GetIndexInTuple<T, ATuple>::value < std::tuple_size<ATuple>::value) >;
99
100 }
102}
Abstract base class for different kinds of events.
STL namespace.
Structure to serve as a placeholder for a variadic initializer list of statements to be evaluated.
Definition: EvalVariadic.h:37
EvalVariadic(Ts &&... expressions)
Constructor taking the variadic initializer list.
Definition: EvalVariadic.h:40
AType Type
Result first item of the variadic sequence.
Definition: EvalVariadic.h:67
AType Type
Result first item of the variadic sequence.
Definition: EvalVariadic.h:60
Helper type to take the first type of a variadic sequence of types.
Definition: EvalVariadic.h:48
Looks up, at which index the given Type can be found in a tuple.
Definition: EvalVariadic.h:78