While the mfontanini solution works, and thatβs good because it does the calculation of the index of the incremental column at compile time, I find it useful to indicate that there is also a direct answer to the question of how to increase int in the extension of the variational package, (Unfortunately It does not work on GCC due to an error, see Disclaimer at the end.)
The answer is based on the fact that, although the argument estimates in the function call are not affected, the argument estimates in the list initialization are not:
(Β§8.5.4 / 4) In a list of initializers, linked to initialization, initializer offers, including all that result from decomposing packages (14.5.3), are evaluated in the order in which they appear. That is, each calculation of the values ββand the side effect associated with the given initializer clause are sequenced before each calculation of the value and the side effect associated with any initializer clause that follows it in the comma-separated list of initializers.
[Note. This ranking ordering is performed independently of the initialization semantics; for example, it is used when elements of an initializer list are interpreted as arguments to a constructor call, although there is usually no sequence restriction on call arguments. - final note]
Therefore, if you convert a function call to something based on a list of parentheses, you get the desired effect:
rowCallback(std::tuple<ColumnTypes...> { getColumn<ColumnTypes>(column++)... });
This initializes a std::tuple using list initialization (note the curly braces { ... } ), so the side effect of column++ will be executed in order from left to right.
If written as above, this means that you need to modify rowCallback() so that it accepts std::tuple instead of the argument list. If you don't like this, you can create a separate call_on_tuple(fun,tup) template function that calls any fun function for the arguments that result from the tuple tup . I somehow described how to do it here , or if you like, you can use rlxutil::call_on_tuple from my GitHub repository .
Your execute function is as follows:
template <typename... ColumnTypes> void execute(function<void(ColumnTypes...)> rowCallback) { using std::tuple; using rlxutil::call_on_tuple; int column = 0; call_on_tuple(rowCallback, tuple<ColumnTypes...> { getColumn<ColumnTypes>(column++)... }); }
Warning. This does not work with GCC. I believe this is due to the error message: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253 .