If the concern is that the addition with other fees is not done within the function, as documented the caller can set the in/out argument to zero before calling. I could also always return only the value for the single transaction without accumulating anything (although I don't see the gain, it's just more code), at that point the argument would be out only, not in/out.
From there, to return the output argument as a tuple or pair I think it's just making things uglier and unnecessarily complicated.
instead of:
CAmount tx_fee = 0; // You will initialize the variable even if the function starts setting it to zero
if (!CheckTxInputs(..., tx_fee))
return false;
accumulated_fee += tx_fee;
You would have something like:
struct CheckTxInputsReturn
{
bool fValid;
CAmount tx_fee;
}
CheckTxInputsReturn ret = CheckTxInputs(...);
if (!ret.fValid)
return false;
accumulated_fee += ret.tx_fee;
I think that's incredibly ugly. Specially since I don't see the problem with how it is currently used when you don't want to accumulate any fees:
CAmount tx_fee = 0;
if (!CheckTxInputs(..., tx_fee))
return false;
Please, I invite you to write your suggestions on top of this and see for yourselves that they are not an improvement but actually the contrary.
If people agree that those IMO much uglier solutions are better, I will squash your suggestions, no problem.