Hi, I made this suggestion in JIRA, but it is abstract enough that it would be beneficial to discuss it on the forum. Here is the original JIRA issue: sft.its.cern.ch/jira/browse/ROOT-6941
Here is copy-pasted the content of the original JIRA post:
There are several functions and methods in ROOT that use the technique of output parameters, when a parameter is passed by non-const reference in order to be modified. This is done because C++ did not easily allow multiple values to be returned by a function.
This is changed with C++11 with make_pair, make_tuple, and std::tie making it very convenient to have functions with multiple return values (without needing to make a whole custom struct for the purpose).
My proposal would not break any existing code, as it merely adds overloads. Any function that currently takes non-const ref parameters should be overloaded to have an equivalent function returning an std::pair or std::tuple. E.g. for TF1::GetRange, we currently have:
virtual void GetRange(Double_t& xmin, Double_t& xmax) const
My proposal would add:
virtual std::pair<double,double> GetRange() const
A TF2 could instead return an std::tuple<double,double,double,double>, etc. Functions which currently take a mix of input and output parameters could be accomodated the same way. Probably there are some cases where there is ambiguity, but the users could fall back to the input arguments for those cases.
This would be one small step towards making ROOT coding styles more modern, and would make use of output-parameter functions in PyROOT much less cumbersome.