Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RInferenceUtils.hxx
Go to the documentation of this file.
1 #ifndef TMVA_RINFERENCEUTILS
2 #define TMVA_RINFERENCEUTILS
3 
4 #include "ROOT/RIntegerSequence.hxx" // std::index_sequence
5 #include <utility> // std::forward
6 
7 namespace TMVA {
8 namespace Experimental {
9 
10 namespace Internal {
11 
12 /// Compute helper
13 template <typename I, typename T, typename F>
14 class ComputeHelper;
15 
16 template <std::size_t... N, typename T, typename F>
17 class ComputeHelper<std::index_sequence<N...>, T, F> {
18  template <std::size_t Idx>
19  using AlwaysT = T;
20  F fFunc;
21 
22 public:
23  ComputeHelper(F &&f) : fFunc(std::forward<F>(f)) {}
24  auto operator()(AlwaysT<N>... args) -> decltype(fFunc.Compute({args...})) { return fFunc.Compute({args...}); }
25 };
26 
27 } // namespace Internal
28 
29 /// Helper to pass TMVA model to RDataFrame.Define nodes
30 template <std::size_t N, typename T, typename F>
31 auto Compute(F &&f) -> Internal::ComputeHelper<std::make_index_sequence<N>, T, F>
32 {
33  return Internal::ComputeHelper<std::make_index_sequence<N>, T, F>(std::forward<F>(f));
34 }
35 
36 } // namespace Experimental
37 } // namespace TMVA
38 
39 #endif // TMVA_RINFERENCEUTILS