February 25, 2019 Variadic template parameter (for mixin) does not work | ||||
---|---|---|---|---|
| ||||
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? |
February 25, 2019 Re: Variadic template parameter (for mixin) does not work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Porton | 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 |
Copyright © 1999-2021 by the D Language Foundation