LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar::util::details::FitDataCollector< T, D >::SumExtractor< Power, N > Struct Template Reference

Static Public Member Functions

static T Sum (WeightTracker< T > const &, DataTracker< Power, T > const &sums)
 

Detailed Description

template<typename T, unsigned int D>
template<unsigned int Power, unsigned int N>
struct lar::util::details::FitDataCollector< T, D >::SumExtractor< Power, N >

The "extractor" is just a C++ trick to replace a statement like:

(N == 0)? weight.Weights(): sums.template SumN<N>()

where N is a constexpr number. The problem is that SumN<0> is not valid (in our case, it raises a static assertion). The analysis of the full statement shows that it would not be a problem, since the compiler could remove the ternary operator since it always knows whether N is 0 or not. Matter of fact, the compiler can also choose to be dumb and compile the whole thing, including a SumN<0>.

The trick is in the form of a class that gets specialized for N = 0. A long list of limitations in C++ (up to 2014 at least) forces the implementation in a struct.

Definition at line 56 of file SimpleFits.h.

Member Function Documentation

template<typename T , unsigned int D>
template<unsigned int Power, unsigned int N>
static T lar::util::details::FitDataCollector< T, D >::SumExtractor< Power, N >::Sum ( WeightTracker< T > const &  ,
DataTracker< Power, T > const &  sums 
)
inlinestatic

Definition at line 57 of file SimpleFits.h.

58  {
59  return sums.template SumN<N>();
60  }

The documentation for this struct was generated from the following file: