diff --git a/Framework/Core/include/Framework/HistogramRegistry.h b/Framework/Core/include/Framework/HistogramRegistry.h index 4b96ce75bbc98..1bd3bf9ece00c 100644 --- a/Framework/Core/include/Framework/HistogramRegistry.h +++ b/Framework/Core/include/Framework/HistogramRegistry.h @@ -39,10 +39,14 @@ namespace o2::framework * Static helper class to fill root histograms of any type. Contains functionality to fill once per call or a whole (filtered) table at once. */ //************************************************************************************************** +template +concept FillValue = std::is_integral_v || std::is_floating_point_v || std::is_enum_v; + struct HistFiller { // fill any type of histogram (if weight was requested it must be the last argument) template - static void fillHistAny(std::shared_ptr hist, const Ts&... positionAndWeight); + static void fillHistAny(std::shared_ptr hist, Ts... positionAndWeight) + requires(FillValue && ...); // fill any type of histogram with columns (Cs) of a filtered table (if weight is requested it must reside the last specified column) template @@ -127,7 +131,8 @@ class HistogramRegistry // fill hist with values template - void fill(const HistName& histName, Ts&&... positionAndWeight); + void fill(const HistName& histName, Ts... positionAndWeight) + requires(FillValue && ...); // fill hist with content of (filtered) table columns template @@ -197,7 +202,8 @@ class HistogramRegistry //-------------------------------------------------------------------------------------------------- template -void HistFiller::fillHistAny(std::shared_ptr hist, const Ts&... positionAndWeight) +void HistFiller::fillHistAny(std::shared_ptr hist, Ts... positionAndWeight) + requires(FillValue && ...) { constexpr int nArgs = sizeof...(Ts); @@ -412,11 +418,16 @@ uint32_t HistogramRegistry::getHistIndex(const T& histName) } template -void HistogramRegistry::fill(const HistName& histName, Ts&&... positionAndWeight) +void HistogramRegistry::fill(const HistName& histName, Ts... positionAndWeight) + requires(FillValue && ...) { - std::visit([&positionAndWeight...](auto&& hist) { HistFiller::fillHistAny(hist, std::forward(positionAndWeight)...); }, mRegistryValue[getHistIndex(histName)]); + std::visit([positionAndWeight...](auto&& hist) { HistFiller::fillHistAny(hist, positionAndWeight...); }, mRegistryValue[getHistIndex(histName)]); } +extern template void HistogramRegistry::fill(const HistName& histName, double); +extern template void HistogramRegistry::fill(const HistName& histName, float); +extern template void HistogramRegistry::fill(const HistName& histName, int); + template void HistogramRegistry::fill(const HistName& histName, const T& table, const o2::framework::expressions::Filter& filter) { diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index 86b2e128ebb2c..806aae93be95e 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -17,6 +17,10 @@ namespace o2::framework { +template void HistogramRegistry::fill(const HistName& histName, double); +template void HistogramRegistry::fill(const HistName& histName, float); +template void HistogramRegistry::fill(const HistName& histName, int); + constexpr HistogramRegistry::HistName::HistName(char const* const name) : str(name), hash(runtime_hash(name)),