Problem: Cannot create class out of nothing using witchcraft

DoctorCaptain garble at harble.com
Tue Oct 15 14:12:44 PDT 2013


Fixing links:

> If the template I am trying to instantiate IS NOT variadic, and 
> I pass in an alias of an instantiated template, then the 
> receiving template has all of the type information it needs. 
> Example: dpaste.dzfl.pl/6d618af9

http://dpaste.dzfl.pl/6d618af9

> If the template I am trying to instantiate IS variadic, and I 
> pass in a variadic list of aliases of instantiated templates, 
> then the receiving template appears unable to retrieve all of 
> the type information it needs out of each of the indexes of the 
> variadic parameter. We get close with this next example, but 
> the problem appears to be that it tries to create a static 
> array of the tuple T of length i, instead of indexing into it 
> to get the type (but if you provide an i greater than the 
> actual length of the tuple, it complains about going out of 
> bounds of the tuple length, meaning that it IS in fact aware 
> that it's supposed to be indexing into a type tuple): 
> dpaste.dzfl.pl/ff8a5b9d

http://dpaste.dzfl.pl/ff8a5b9d

> And to be absolutely clear, the underlying goal is to generate 
> a class definition at runtime, which I can mix in and then 
> instantiate, that can contain an arbitrary list of data members 
> that are themselves generated at compile time by their own 
> templates. I have demonstrated that it is possible to do this 
> with a single arbitrary template instantiation in 
> dpaste.dzfl.pl/6d618af9 , but as soon as we try to do it with 
> type tuples, it chokes. I am not sure if this is a compiler bug 
> or I'm just out of my mind, but again, for the sake of academic 
> advancement, lets try to solve the problem in complete 
> disregard of whether we should.

http://dpaste.dzfl.pl/6d618af9


More information about the Digitalmars-d-learn mailing list