www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Variadic template parameter (for mixin) does not work

reply Victor Porton <porton narod.ru> writes:
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?
Feb 25 2019
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
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
Feb 25 2019