Rebind template
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 20 15:21:00 PDT 2016
On 08/21/2016 12:11 AM, 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));
>
> ?
template Rebind(alias instance, newArgs...)
{
import std.traits: TemplateOf;
alias tmpl = TemplateOf!instance;
alias Rebind = tmpl!newArgs;
}
More information about the Digitalmars-d-learn
mailing list