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

2013-12-15 Thread TheFlyingFiddle
template strip(T) if(is(T == delegate)) Typo should be stripped.

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

2013-12-15 Thread TheFlyingFiddle
On Sunday, 15 December 2013 at 10:44:38 UTC, Jacob Carlborg wrote: Hmm, there might be a way to strip all the attributes of a function. template strip(T) if(is(T == delegate)) { alias stripped = ReturnType!T delegate(ParameterTypeTuple!T); } template strip(T) if(is(T == function)) { a

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

2013-12-15 Thread Jacob Carlborg
On 2013-12-14 23:38, DoctorCaptain wrote: This is a very concise way to do what I want to do, but this check cares about other attributes of the function/delegate, i.e. if the function or delegate is designated as pure or nothrow and those don't show up in the check, it will fail. As in: auto n

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

2013-12-14 Thread Philippe Sigaud
I have 3 comments (if you're still reading this thread :) ) First, you could let nextGen determine the return type. Since the template know that nextGen returns an int delegate(int), there is no need for the user to provide the 'int' parameter. So user code could become: void main(string[] argv)

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

2013-12-14 Thread DoctorCaptain
Most uses of the 'is expression' allows using a specifier to name the entity that matched. So, inserting ReturnedDelegate in your '== delegate' line gives the name ReturnedDelegate to the delegate. That name can be used further: template exT(T, alias nextGen) if ( // Ensure next

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

2013-12-14 Thread Jacob Carlborg
On 2013-12-14 20:53, DoctorCaptain wrote: 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! I would

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

2013-12-14 Thread Ali Çehreli
On 12/14/2013 11:53 AM, DoctorCaptain wrote:> 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 t

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

2013-12-14 Thread DoctorCaptain
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 temp