1313#define FRAMEWORK_HISTOGRAMSPEC_H_
1414
1515#include < string>
16+ #include < utility>
1617#include < variant>
1718#include < optional>
1819
@@ -82,17 +83,17 @@ constexpr double VARIABLE_WIDTH = 0.;
8283struct AxisSpec {
8384 AxisSpec (std::vector<double > binEdges_, std::optional<std::string> title_ = std::nullopt , std::optional<std::string> name_ = std::nullopt )
8485 : nBins(std::nullopt ),
85- binEdges (binEdges_),
86- title(title_),
87- name(name_)
86+ binEdges (std::move( binEdges_) ),
87+ title(std::move( title_) ),
88+ name(std::move( name_) )
8889 {
8990 }
9091
9192 AxisSpec (int nBins_, double binMin_, double binMax_, std::optional<std::string> title_ = std::nullopt , std::optional<std::string> name_ = std::nullopt )
9293 : nBins(nBins_),
9394 binEdges({binMin_, binMax_}),
94- title(title_),
95- name(name_)
95+ title(std::move( title_) ),
96+ name(std::move( name_) )
9697 {
9798 if (binMin_ > binMax_) {
9899 LOG (fatal) << " Defined ill-defined axis" ;
@@ -103,8 +104,8 @@ struct AxisSpec {
103104 AxisSpec (ConfigurableAxis binEdges_, std::optional<std::string> title_ = std::nullopt , std::optional<std::string> name_ = std::nullopt )
104105 : nBins(std::nullopt ),
105106 binEdges(std::vector<double >(binEdges_)),
106- title(title_),
107- name(name_)
107+ title(std::move( title_) ),
108+ name(std::move( name_) )
108109 {
109110 if (binEdges.empty ()) {
110111 return ;
@@ -116,7 +117,7 @@ struct AxisSpec {
116117 binEdges.erase (binEdges.begin ()); // remove first entry that we assume to be number of bins
117118 }
118119
119- long getNbins () const ;
120+ [[nodiscard]] long getNbins () const ;
120121
121122 // / Function to make the axis logarithmic
122123 void makeLogarithmic ();
@@ -136,7 +137,7 @@ struct AxisSpec {
136137struct HistogramConfigSpec {
137138 HistogramConfigSpec (HistType type_, std::vector<AxisSpec> axes_, uint8_t nSteps_ = 1 )
138139 : type(type_),
139- axes (axes_),
140+ axes (std::move( axes_) ),
140141 nSteps(nSteps_)
141142 {
142143 }
@@ -151,12 +152,12 @@ struct HistogramConfigSpec {
151152
152153 void addAxis (int nBins_, double binMin_, double binMax_, std::optional<std::string> title_ = std::nullopt , std::optional<std::string> name_ = std::nullopt )
153154 {
154- axes.push_back ({ nBins_, binMin_, binMax_, title_, name_} );
155+ axes.emplace_back ( nBins_, binMin_, binMax_, title_, name_);
155156 }
156157
157158 void addAxis (std::vector<double > binEdges_, std::optional<std::string> title_ = std::nullopt , std::optional<std::string> name_ = std::nullopt )
158159 {
159- axes.push_back ({ binEdges_, title_, name_} );
160+ axes.emplace_back ( binEdges_, title_, name_);
160161 }
161162
162163 void addAxes (std::vector<AxisSpec> axes_)
@@ -185,22 +186,17 @@ struct HistogramSpec {
185186 : name(name_),
186187 hash (compile_time_hash(name_)),
187188 title(title_),
188- config(config_),
189+ config(std::move( config_) ),
189190 callSumw2(callSumw2_)
190191 {
191192 }
192193
193- HistogramSpec ()
194- : name(" " ),
195- hash(0 ),
196- config()
197- {
198- }
194+ HistogramSpec () = default;
199195 HistogramSpec (HistogramSpec const & other) = default;
200196 HistogramSpec (HistogramSpec&& other) = default;
201197
202198 std::string name{};
203- uint32_t hash{} ;
199+ uint32_t hash = 0 ;
204200 std::string title{};
205201 HistogramConfigSpec config{};
206202 bool callSumw2{}; // wether or not hist needs heavy error structure produced by Sumw2()
0 commit comments