On Sunday, 11 December 2016 at 22:18:02 UTC, Adam D. Ruppe wrote:
On Sunday, 11 December 2016 at 22:00:27 UTC, Kevin Balbas wrote:
Basically, I need some way to turn an array of strings
into an argument list at runtime. Is this possible?
Write (or generate) a helper function that loops over the
Parameters!Func tuple and populates it from the strings. Call
the helper function.
// declare your arguments tuple
Parameters!Func args;
// populate the arguments
foreach(idx, ref arg; args) {
arg = to!(typeof(arg))(string_args[idx]);
}
Func(args); // call the function with that tuple
The free sample of my book:
https://www.packtpub.com/application-development/d-cookbook has
a more in-depth example near the end of it.
I see. I was planning on doing a wrapper-based approach to the
function calls if this didn't work out, but I didn't expect it'd
be that simple. Thanks for the tip.