digitalmars.D.learn - Variadic template parameter (for mixin) does not work
- Victor Porton (5/5) Feb 25 2019 I want to create a mixin with an arbitrary number of parameters.
- H. S. Teoh (12/20) Feb 25 2019 All you need is:
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
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