this T / variadic template and interfaces
frame
frame86 at live.com
Tue Oct 27 09:40:33 UTC 2020
On Monday, 26 October 2020 at 13:02:33 UTC, Jacob Carlborg wrote:
> 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
Hmm, a question of design. Is there also a convenient way to pass
the arguments to a template or get a Variant[] from it?
More information about the Digitalmars-d-learn
mailing list