Rebind template

Alexandru Ermicioi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 21 13:10:12 PDT 2016


On Saturday, 20 August 2016 at 22:18:57 UTC, Engine Machine wrote:
> On Saturday, 20 August 2016 at 22:11:40 UTC, Engine Machine 
> wrote:
>> Is there a way to rebind the arguments of a template?
>>
>> template foo(X)
>> {
>>    // X is like A!(a,b,c)
>>    Y = Rebind!(X,d,e,f);
>>    // Y is like A!(d,e,f);
>> }
>>
>> foo(A!(a,b,c));
>>
>> ?
>
> I'd also be happy if I could just remove the last element from 
> A.
>
> template EraseLast(X)
> {
>     // returns A!(a,b) when X = A!(a,b,c)
> }

Check for ApplyLeft and ApplyRight in std.meta, maybe it can help 
you.

http://dlang.org/phobos/std_meta.html#.ApplyLeft
http://dlang.org/phobos/std_meta.html#.ApplyRight


More information about the Digitalmars-d-learn mailing list