Overloaded arithmetic operators for 2d and 3d histograms: offensive parameter types

Why do the overloaded arithmetic operators accept histograms by lvalue-reference to non-const?
It is impossible to construct non-trivial expressions with histograms!
Had to add my own overloads with rvalue-reference parameters! Thankfully, I can just call the ROOT’s offensive operators from my own and don’t have to re-implement the functionality, but still.

I see

TH1C operator+(const TH1C &h1, const TH1C &h2);
TH1C operator-(const TH1C &h1, const TH1C &h2);
TH1C operator*(const TH1C &h1, const TH1C &h2);
TH1C operator/(const TH1C &h1, const TH1C &h2);

etc. So which ones are you referring to?

I’m referring to operators for TH2 and TH3 (updated the title), e.g.

TH2D 	operator* (TH2D &h1, TH2D &h2)
TH2D 	operator+ (TH2D &h1, TH2D &h2)
TH2D 	operator- (TH2D &h1, TH2D &h2)
TH2D 	operator/ (TH2D &h1, TH2D &h2)

Yuck. @moneta what do you think? :wink:

Hi,

I think this is a mistake in the design. In the 2D and 3D cases, they should take const reference as in 1D. Can you please issue a JIRA items for this ?
Thank you
Lorenzo

Here it is Loading...

Thank you very much !
Best Regards
Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.