Meta:

alias list1 = Cons!(Three, Cons!(Two, Cons!(Four, Cons!(One, Nil))));

alias numlHead(L: Cons!(a, b), a, b) = a;

alias numlTail(L: Cons!(a, b), a, b) = b;


But the compiler is complaining loudly about a mismatch:

/d43/f234.d(39): Error: template instance numlHead!(list1) does not match template declaration numlHead(L : Cons!(a, b), a, b)

See a recent thread of mine:
http://forum.dlang.org/thread/vlwgufdlpjgewpnnh...@forum.dlang.org

Currently I think you have to accept types and aliases with a regular template syntax, and verify the types and kinds with template constraints. Something like (untested):

template numlTail(C) if (TemplateOf!(C, Cons)) {
    alias numlTail = TemplateArgsOf!(C)[1];
}

Bye,
bearophile

Reply via email to