Get rid of the erase
and add an index. Do not mutate data used in other parameter calculations when making a function call, as the order is undefined (which lets the compiler reorder them for efficiencies sake, or the phase of the miin).
You will need to add one level of indirection to do this easily:
template<unsigned...>struct indexes {};
template<unsigned num, unsigned... Is>struct make_indexes:
make_indexes<num-1, num-1, Is...>{};
template<unsigned...Is>struct make_indexes<0,Is...>:indexes<Is...>{};
template<typename... Args, unsigned...Is>
void do_call(indexes<Is...>, ValArray& arr){
call( fnPtr, ProcessParam<Args>( arr[Is] )... );
}
where ProcessParam
now takes an element not an array, and use it like:
do_call<Args...>( make_indexes<sizeof...(Args)>(), arr );