instantiate each of a tuple of templates (Take 2)

John Colvin john.loughran.colvin at gmail.com
Thu Aug 1 08:08:52 PDT 2013


On Thursday, 1 August 2013 at 14:57:07 UTC, monarch_dodra wrote:
> On Thursday, 1 August 2013 at 12:50:42 UTC, John Colvin wrote:
>> template a(T ...)
>> {
>>    void a(R r)
>>    {
>>        //want to get a tuple of
>>        //the members of T, each
>>        //instantiated with R.
>>
>>        //do some RT stuff
>>    }
>> }
>>
>> Is this possible?
>>
>> Whatever I try, I keep running in to "cannot use local as 
>> parameter to non-global template" errors, which I understand 
>> is to do with context pointers
>> However, this is all compile-time work based entirely on 
>> types, there should be no need for any context pointers.
>
> Still not sure what you want, but you may want to look into 
> adjoin and  staticMap.

Sorry, now I've thought about it some more it appears I was 
asking the wrong question completely!

Here's the situation (you might recognise the pattern from 
std.algorithm.map):

template a(funs...)
{
     auto a(R)(R r)
     {
         alias /*something*/ nonVoidFuns;
         alias /*something*/ voidFuns;

         //do stuff with nonVoidFuns and voidFuns applied to r
     }
}

so i need to find the return type of each fun, when called with 
something of type R (bearing in mind that fun!R may not be the 
same type as fun(r) as fun might be T fun(T)(T[] a), then filter 
funs to seperate the void functions from the non-void ones. Or 
something else to that effect.

I've tried several things with std.typetuple.Filter but nothing 
seems to work.


More information about the Digitalmars-d-learn mailing list