CbmRoot
Loading...
Searching...
No Matches
AlgoTraits.h
Go to the documentation of this file.
1/* Copyright (C) 2024 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer] */
4
5#pragma once
6
7#include <tuple>
8#include <type_traits>
9
16{
17
18 namespace detail
19 {
20 template<typename...>
21 struct ResultOf {
22 };
23
24 template<typename R, typename Algo, typename... Args>
25 struct ResultOf<R (Algo::*)(Args...) const> {
26 using type = R;
27 };
28
29 template<typename R, typename Algo, typename... Args>
30 struct ResultOf<R (Algo::*)(Args...)> {
31 using type = R;
32 };
33
34 template<typename Algo>
35 struct ResultOf<Algo> : ResultOf<decltype(&Algo::operator())> {
36 };
37
38 } // namespace detail
39
43 template<typename Algo>
45
46 // Currently assume algorithms return std::tuple<R, M, A>
47 // where R is the output, M is the monitoring data and A is auxiliary data
48
52 template<typename Algo>
53 using Output_t = typename std::tuple_element<0, ResultOf_t<Algo>>::type;
54
58 template<typename Algo>
59 using Monitor_t = typename std::tuple_element<1, ResultOf_t<Algo>>::type;
60
64 template<typename Algo>
65 using Aux_t = typename std::tuple_element<2, ResultOf_t<Algo>>::type;
66
67} // namespace cbm::algo::algo_traits
typename std::tuple_element< 0, ResultOf_t< Algo > >::type Output_t
Type alias for the output type produced by an algorithm.
Definition AlgoTraits.h:53
typename std::tuple_element< 2, ResultOf_t< Algo > >::type Aux_t
Type alias for the auxiliary data type produced by an algorithm.
Definition AlgoTraits.h:65
typename detail::ResultOf< Algo >::type ResultOf_t
Type alias for the return type produced by an algorithm when invoked via callable-operator.
Definition AlgoTraits.h:44
typename std::tuple_element< 1, ResultOf_t< Algo > >::type Monitor_t
Type alias for the monitoring type produced by an algorithm.
Definition AlgoTraits.h:59