How to transform types from variadic template parameters to another type?
For example:
template
struct single
{
std::tuple&l
You can do more than just expand a variadic parameter pack as a plain list: you can expand an expression too. You can therefore have m_sequences
be a tuple of vectors rather than a tuple of the elements:
template
struct sequences
{
std::tuple...> m_sequences;
};
You can also do nifty tricks with parameter packs to pick the appropriate element from the vector:
template struct indices_holder
{};
template >
struct make_indices_impl;
template
struct make_indices_impl >
{
typedef typename make_indices_impl<
index_to_add-1,
indices_holder >::type type;
};
template
struct make_indices_impl<0,indices_holder >
{
typedef indices_holder type;
};
template
typename make_indices_impl::type make_indices()
{
return typename make_indices_impl::type();
}
template
struct sequences
{
std::tuple...> m_sequences;
template
std::tuple get_impl(size_t pos,indices_holder)
{
return std::make_tuple(std::get(m_sequences)[pos]...);
}
std::tuple get(size_t pos)
{
return get_impl(pos,make_indices());
}
};