Variadic template parameter (for mixin) does not work

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Feb 25 20:33:25 UTC 2019


On Mon, Feb 25, 2019 at 08:23:10PM +0000, Victor Porton via Digitalmars-d-learn wrote:
> I want to create a mixin with an arbitrary number of parameters.
> 
> I tried this:
> 
> mixin template ProviderParams(Types...)(Types t) {
> }
> 
> But it does not compile. What's my error?

All you need is:

	mixin template ProviderParams(Values...) {
		...
	}

Template arguments don't have to be types, they can be anything that can
be evaluated at compile-time. You'd instantiate the above mixin like
this, for example:

	mixin ProviderParams!(123, "abc", 3.14f);


T

-- 
GEEK = Gatherer of Extremely Enlightening Knowledge


More information about the Digitalmars-d-learn mailing list