this T / variadic template and interfaces

Jacob Carlborg doob at me.com
Tue Oct 27 10:41:06 UTC 2020


On Tuesday, 27 October 2020 at 09:40:33 UTC, frame wrote:

> Hmm, a question of design. Is there also a convenient way to 
> pass the arguments to a template or get a Variant[] from it?

Convenient, no not that I know of. You can use a type safe 
variadic function that takes Variant, if you want to end up with 
Variant[] anyway. It depends on how you want the API to look 
like. Here are some examples:

void foo(...);
void bar(Variant[] args ...);

foo(3, "foo", 'a'); // pass in the arguments as is
bar(Variant(3), Variant("foo"), Variant('a')); // need to wrap 
each argument in Variant

The advantage of using the type safe variadic function is that 
all the arguments are bundle into one array, make it easier to 
work with.

--
/Jacob Carlborg



More information about the Digitalmars-d-learn mailing list