Re: Map type to class instance at compile-time

2016-11-05 Thread pontius via Digitalmars-d-learn
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.

Re: Map type to class instance at compile-time

2016-10-27 Thread pontius via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 18:19:33 UTC, Ali Çehreli wrote: There are different approaches but I think the solution above achieves what you want: DefaultManager!(A) is managing an object of A DefaultManager!(B) is managing an object of B SomeCustomManager is managing an object of C Ali

Map type to class instance at compile-time

2016-10-26 Thread pontius via Digitalmars-d-learn
Apologies for the long post or stupid questions, I only started to learn D today. I have a use case where various types (A, B, C) need to be associated with instances of different classes (ManagerA, ManagerB, ManagerC). A certain object (globalManager) should redirect operations on those types