First off, the indices machinery to create a pack of integral indices at compile time:
template< std::size_t... Ns >
struct indices {
typedef indices< Ns..., sizeof...( Ns ) > next;
};
template< std::size_t N >
struct make_indices {
typedef typename make_indices< N - 1 >::type::next type;
};
template<>
struct make_indices< 0 > {
typedef indices<> type;
};
Now, you can create an array of objects:
T vars[] = { T()... };
Next, you need a helper function to create a context where you can deduce the pack of integers. Something like this:
template<typename... T, T, size_t... I>
int helper(type_X params, T* arr, indices<I...>)
{
return b_.get(params, arr[I]...);
}
For arr
parameter you'd pass the array vars
you created previously and for the last one you pass make_indices<sizeof...(T)>::type()
.
Hope that helps.