Re: Array of templated classes or structs

2015-10-26 Thread Dandyvica via Digitalmars-d-learn
On Saturday, 24 October 2015 at 19:02:50 UTC, TheFlyingFiddle wrote: On Saturday, 24 October 2015 at 19:00:57 UTC, TheFlyingFiddle wrote: One thing about variant is that if the struct you are trying to insert is larger then (void delegate()).sizeof it will allocate the wrapped type on the gc he

Re: Array of templated classes or structs

2015-10-24 Thread TheFlyingFiddle via Digitalmars-d-learn
On Saturday, 24 October 2015 at 19:00:57 UTC, TheFlyingFiddle wrote: One thing about variant is that if the struct you are trying to insert is larger then (void delegate()).sizeof it will allocate the wrapped type on the gc heap. This is not a concern if you want to have class templates as the

Re: Array of templated classes or structs

2015-10-24 Thread TheFlyingFiddle via Digitalmars-d-learn
On Saturday, 24 October 2015 at 18:40:02 UTC, TheFlyingFiddle wrote: To complete TemplateStruct simply forward the remaing members of the variant. Or use something like proxy!T in std.typecons. Or use an alias this v. (I don't really recommend alias this it has all kinds of problems) One thin

Re: Array of templated classes or structs

2015-10-24 Thread TheFlyingFiddle via Digitalmars-d-learn
On Saturday, 24 October 2015 at 18:29:08 UTC, TheFlyingFiddle wrote: Variant[] array; array ~= S!int(...); array ~= S!double(...); array ~= S!long(...); array ~= "I am a string!"; And this is probably not what you want. You can do this if you want to ensure that items stored in the variant ar

Re: Array of templated classes or structs

2015-10-24 Thread TheFlyingFiddle via Digitalmars-d-learn
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote: Hi guys, Apart from deriving from the same class and declaring an array of that root class, is there a way to create an array of templates? This seems not possible since template are compile-time generated, but just to be sure. F

Re: Array of templated classes or structs

2015-10-24 Thread qsdfghjk via Digitalmars-d-learn
On Saturday, 24 October 2015 at 17:06:13 UTC, Dandyvica wrote: On Saturday, 24 October 2015 at 16:58:58 UTC, qsdfghjk wrote: On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote: Hi guys, Apart from deriving from the same class and declaring an array of that root class, is there a w

Re: Array of templated classes or structs

2015-10-24 Thread Dandyvica via Digitalmars-d-learn
On Saturday, 24 October 2015 at 16:58:58 UTC, qsdfghjk wrote: On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote: Hi guys, Apart from deriving from the same class and declaring an array of that root class, is there a way to create an array of templates? This seems not possible sin

Re: Array of templated classes or structs

2015-10-24 Thread qsdfghjk via Digitalmars-d-learn
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote: Hi guys, Apart from deriving from the same class and declaring an array of that root class, is there a way to create an array of templates? This seems not possible since template are compile-time generated, but just to be sure. F

Array of templated classes or structs

2015-10-24 Thread Dandyvica via Digitalmars-d-learn
Hi guys, Apart from deriving from the same class and declaring an array of that root class, is there a way to create an array of templates? This seems not possible since template are compile-time generated, but just to be sure. For example, it seems logical to get an array of complex numbers