How to obtain certain traits of delegates returned by functions in template constraints?

DoctorCaptain garble at harble.com
Sat Dec 14 11:53:36 PST 2013


My question is hopefully short and straightforward to answer, but 
it's also a two-parter.

I am working on a template that generates a function that 
implements an algorithm using several helper functions that are 
provided to the template by the user. I would like to add 
constraints to the template to restrict what functions the user 
can attempt to instantiate the template with, as the algorithm 
implemented by a function in the template has specific 
requirements. One of the functions required by the template needs 
to return a delegate so that it can be used as a generator of 
sorts. In any case. I have the ability to check the return type, 
arity, and parameter list of a function in the constraints of the 
template, and I can also check the return type of the delegate 
returned by the function.

So, first, how do I check the arity of and retrieve a parameter 
type tuple of the delegate returned by the function? Hopefully 
the example code in the following dpaste will fully illustrate my 
question:

http://dpaste.dzfl.pl/ef1a970f

Second, can I get the level of thoroughness I am going for in 
these constraints checks with fewer actual checks? As in, is 
there a more straightforward way to do these checks without 
sacrificing any of them?

Thank you for any and all insight!


More information about the Digitalmars-d-learn mailing list