Call a function passed as template parameter.

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 3 06:16:39 PDT 2015


On Thursday, 3 September 2015 at 11:31:22 UTC, moechofe wrote:
> I would like to create a template that take a function as 
> template parameter, create an arguments list for it, fill it 
> with some data and call the function.

Check out the sample chapter to my book:
https://www.packtpub.com/application-development/d-cookbook

This is one of the examples I explain there that uses this basic 
idea to convert strings to parameters:

http://arsdnet.net/dcode/book/chapter_08/11/caller.d

Or, a real world example I've written is here:

https://github.com/adamdruppe/arsd/blob/master/jsvar.d#L608

which is similar to what you're trying to do, though JSONValue 
will be a bit harder to convert than my `var`.


More information about the Digitalmars-d-learn mailing list