I've got a template function taking a parameter pack. I want to expand it into calls to a second function while also supplying the index of the item in the pack. I probably can work out how to do it with recursion but I would like to try do it with a fold expression.
This is the function I want the parameter pack to expand into
template<typename T>
void addToRecord(Record& rec, int idx, T&& val)
{
// Do some stuff.
}
And this is the function that takes the parameter pack
template<typename... ARGS>
void addRecord(ARGS&& ...values)
{
Record rec;
// addToRecord(rec, ??????) How do expand 'values' here addToRecord with index of each item?
}
Is this possible? I realize this isn't critical but I'm also trying to get better with using fold expressions.