Skip to content

Add 2D constructor for Histogram to allow construction with make_unique etc

The current generic Histogram constructor Histogram(OWNER*, string, string, initializer_list<Axis>) isn't recognised by make_unique, etc so it's not currently possible to create a smart pointer to a >1D histogram (1D histograms having an alternative constructor already):

../GaudiKernel/tests/src/CounterHistosUnitTest.cpp:135:15: error: no matching function for call to 'make_unique'
  auto hist = std::make_unique<Histogram<2, atomicity::full, float>>(&algo, "Test2DHist", "Test 2D histogram", {{10, 0., 10.}, {10, 0., 10.}});
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This MR adds a 2D constructor analogous to the existing 1D case and a test to show that it can be used to create a unique_ptr.

Merge request reports