Map type to class instance at compile-time

pontius via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 5 11:55:37 PDT 2016


On Thursday, 27 October 2016 at 19:16:03 UTC, Ali Çehreli wrote:
> The problem is with that line. In the previous design, 
> ManagerRegistrationFor would generate a manage() template 
> instance for T and mix it in to the scope. As a result 
> manage(t) would be bound to it the correct template instance.
>
> Now, because manager.d does not have that instance here, it 
> needs to refer to it with the full template name:
>
>     ManagerRegistrationFor!(T, ???).manage(t);
>
> would work but we don't have the 'alias mgr' argument to refer 
> to it (hence my question marks). I don't think it's ever 
> possible to fully-qualify a template mixin that has an alias 
> argument. (Yes, it would be possible if the user also had 
> access to the same aliased symbol.)
>
> So, I think the problem is with the new design; we need to get 
> rid of that alias parameter and pass the manager object as a 
> runtime parameter.
>
> Ali

Heck, I should have noticed that the overloads are created in the 
wrong module. I would like to use alias here, because 
instantiation via string mixin places arbitrary restrictions on 
my users' constructors. I hope a better way is possible.
Nevertheless, thank you for your help, the examples were very 
useful for me.


More information about the Digitalmars-d-learn mailing list