ADL

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 4 18:00:26 PDT 2016


On 9/4/2016 1:48 PM, Ethan Watson wrote:
> Chipping in to say that I currently do something this with Binderoo templates...
> and it sucks.

What about using this template?

// Find module in which T was defined
template ModuleOf(alias T)
{
     import std.traits : moduleName;
     mixin("import " ~ moduleName!T ~ ";");
     mixin("alias ModuleOf = " ~ moduleName!T ~ ";");
}

and it only has to be written once. Yes, it uses CTFE and mixins, but it's all 
hidden away inside the template.


More information about the Digitalmars-d mailing list