CTAD and even elements of a parameter pack
I'm building a library for random sampling, where a sampler is anything callable with a URBG (basically a distribution, but without the RandomNumberDistribution required)
I've implemented a Mixture<Samplers...> that is a mixture of samplers, weighted.
I want to create one by calling a variadic constructor, alternating samplers and weights, e.g.
auto mixture = Mixture{sampler_1, w_1, ..., sampler_n, w_n};
I've implemented a variadic ctor that correctly dispatches samplers and weights, but it does not work withut a deduction guide...which I can't implement :(
My understanding is that I would need to write
template <typename... Args>
requires (sizeof...(Args) % 2 == 0)
Mixture(Args&&...)
-> Mixture<EvenArgs...>; // this needs to be of the form Mixture<Samplers...>!?
How can I extract only the even elements of a parameter pack, so that I can implement the above guide?
Or can you suggest another technique that I can use to make my desired call site compile?
Posted Aug 5, 2026, 1:30 PM UTC