Helper mixin template wrapping functions in a foralls.
Given a template symbol, a list a type variables Variables, and a name $(name), this mixin generates two symobls underscore ~ name and name.
Where underscore ~ name is a private symbol with free variables and name is the former wrapped in a forall type.
// generic identity function in idiomatic DAidentityGeneric(A)(Ax)
{
returnx;
}
// generate the symbol "_identityPtr" and the "identityPtr" wrappermixinErasure!(identityGeneric, "identityPtr", α!("A", (void*).sizeof));
// redefine for clearityenumΠ!("A", α!("A", (void*).sizeof) function(α!("A", (void*).sizeof))) identity = identityPtr;
// usageunittest
{
int* x = newint(1);
assert(*identity.specialize!(int*)()(x) == 1);
}
Helper mixin template wrapping functions in a foralls. Given a template symbol, a list a type variables Variables, and a name $(name), this mixin generates two symobls underscore ~ name and name. Where underscore ~ name is a private symbol with free variables and name is the former wrapped in a forall type.