Coming from this earlier question on finding the number of unique values of a parameter pack, has made me think, if it is feasible to pass/forward a selected number of variadic parameter pack to another function or to return them, for instance, assume we have a struct
that takes a homogeneous pack
template<size_t ... Rest>
struct my_struct;
I would like to have a function foo
that takes this parameter pack and returns another struct
with unique values of the parameter pack passed to it, something like
template<size_t N, size_t ... Rest>
my_struct<uniques<N,Rest...>> foo(const my_struct<N,Rest...> &a) {
// do stuff
}
As an example:
my_struct<0,5,2,0,4,2> a;
my_struct<0,5,2,4> b = foo(a);
Sorting the values, is not of any interest here. Is this functionality possible to achieve using only the standard library?