this T / variadic template and interfaces

Jacob Carlborg doob at me.com
Mon Oct 26 13:02:33 UTC 2020


On Monday, 26 October 2020 at 11:14:47 UTC, frame wrote:

> Is there any way to get this working? I know, I could use a 
> known object to feed the arguments and use that instead - but I 
> want to keep things simple as possible.

As Simen mentioned, templates cannot be virtual. But you don't 
need to use a template, you can use a regular variadic method 
[1]. It's a bit more clunky to work with than template variadic 
functions. Or if all the arguments will be of the same type, you 
can use type safe variadic functions [2], which are easier to 
work with.

[1] 
https://dlang.org/spec/function.html#d_style_variadic_functions
[2] 
https://dlang.org/spec/function.html#typesafe_variadic_functions

--
/Jacob Carlborg



More information about the Digitalmars-d-learn mailing list