Lodestar
An integrated real-time control package in C++
FunctionTraits.hpp
1 //
2 // Created by Hamza El-Kebir on 12/30/2021.
3 //
4 
5 #ifndef LODESTAR_FUNCTIONTRAITS_HPP
6 #define LODESTAR_FUNCTIONTRAITS_HPP
7 
8 #include <functional>
9 
10 namespace ls {
11  namespace aux {
12  template<typename TType>
13  struct FunctionTraits : public FunctionTraits<decltype(&TType::operator())> {
14  };
15 
16  template<typename TClass, typename TReturn, typename... TArgs>
17  struct FunctionTraits<TReturn(TClass::*)(TArgs...) const> {
18  enum {
19  arity = sizeof...(TArgs)
20  };
21 
22  using res = TReturn;
23 
24  template<int I>
25  struct arg {
26  static_assert(((I >= 0) && (I < arity)), "Argument index out of range.");
27  using type = typename ::std::tuple_element<I, ::std::tuple<TArgs...>>::type;
28  };
29 
30  using func = ::std::function<TReturn(TArgs...)>;
31  };
32  }
33 }
34 
35 #endif //LODESTAR_FUNCTIONTRAITS_HPP
ls
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
ls::aux::FunctionTraits
Definition: FunctionTraits.hpp:13