Problem: Cannot create class out of nothing using witchcraft

Benjamin Thaut code at benjamin-thaut.de
Wed Oct 16 11:47:30 PDT 2013


Am 16.10.2013 16:08, schrieb Benjamin Thaut:
> Am 16.10.2013 10:40, schrieb DoctorCaptain:
>>
>> http://dpaste.dzfl.pl/07b20d75
>>
>> Note the use of typeof() to get the type of the elements at each index
>> of members, to generate a type on which a constructor can be called to
>> instantiate the elements at each index of members. Magic.
>
> There is actually a easier way to instanciate the elements. Just do "new
> T[i]();" no need for typeof.
>
>

I'm actually wrong. "new T[i]()" will not work because the compiler will 
think it is a array allocation. You actually have to use new 
typeof(member[i])();

I created a example which generates individual class members for each of 
the arguments bassed to GrabBagT:

http://dpaste.dzfl.pl/eef2edec

-- 
Kind Regards
Benjamin Thaut


More information about the Digitalmars-d-learn mailing list