I am trying avoid output arguments in my functions. The old function is:
void getAllBlockMeanError(
const vector<int> &vec, vector<int> &fact, vector<int> &mean, vector<int> &err)
Here vec is input argument, fact, mean and err are output argument. I tried to group output argument to one tuple:
tuple< vector<int>, vector<int>, vector<int> >
getAllBlockMeanErrorTuple(const vector<int> &vec)
{
vector<int> fact, mean, err;
//....
return make_tuple(fact, mean, err);
}
Now I can call the new function with:
tie(fact, mean, err) = getAllBlockMeanErrorTuple(vec);
It looks cleaner to me. While I have a question, how does equal assignment of tie(fact, mean, err) work? Does it do a deep copy or a move? Since fact, mean and err inside getAllBlockMeanErrorTuple will be destroyed, I hope it is doing a move instead of a deep copy.
make_tuple(), then they should be moved.struct Result { vector<int> fact; vector<int> mean; vector<int> err; };instead of tuple to have better naming for getter.