xxxxxxxxxx
auto withAlloc(alias alloc)()
{
struct SList {
this(T)(int n, T alloc) {}
}
struct DList {
this(T)(int n, T alloc) {}
}
struct Alloc
{
template opDispatch(string op)
{
auto opDispatch(Args...)(auto ref Args args) if(__traits(compiles, mixin(op ~ "(args, alloc)")))
{
mixin("return " ~ op ~ "(args, alloc);");
}
}
}
Alloc result;
return result;
}
struct DumbAlloc { }
void main() {
auto alloc = new DumbAlloc;
with(withAlloc!alloc())
{
auto slist = SList(0);
auto dlist = DList(0);
}
}