Re: turning an array of structs into a struct of arrays

2015-07-06 Thread Vlad Levenfeld via Digitalmars-d-learn
On Sunday, 5 July 2015 at 00:07:59 UTC, Laeeth Isharc wrote: Posted short write-up here. Please make it better... http://wiki.dlang.org/Transforming_slice_of_structs_into_struct_of_slices In John Colvin's solution, should alias TransformMembers(alias TypeTransform, alias

Re: turning an array of structs into a struct of arrays

2015-07-06 Thread John Colvin via Digitalmars-d-learn
On Monday, 6 July 2015 at 17:35:22 UTC, Vlad Levenfeld wrote: On Sunday, 5 July 2015 at 00:07:59 UTC, Laeeth Isharc wrote: Posted short write-up here. Please make it better... http://wiki.dlang.org/Transforming_slice_of_structs_into_struct_of_slices In John Colvin's solution, should

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Artur Skawina via Digitalmars-d-learn
On 07/03/15 12:52, Laeeth Isharc via Digitalmars-d-learn wrote: I have an array of structs eg struct PriceBar { DateTime date; double open; double high; double low; double close; } (which fields are present in this particular struct will depend on template arguments).

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Laeeth Isharc via Digitalmars-d-learn
I can use FieldTypeTuple and FieldNameTuple, but I am a bit lost as to how without static foreach to loop through these in order to generate a mixin to declare the new type. I can turn it into a string, but what is the better option? The simplest solution is something like: template

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Laeeth Isharc via Digitalmars-d-learn
Posted short write-up here. Please make it better... http://wiki.dlang.org/Transforming_slice_of_structs_into_struct_of_slices

Re: turning an array of structs into a struct of arrays

2015-07-03 Thread Laeeth Isharc via Digitalmars-d-learn
Not necessarily the best solution to the problem, but I just wanted to show this because I think it's kinda cool: https://gist.github.com/John-Colvin/103d3c064ad6cb4cf435#file-transformmembers-d Very impressive - now I have to try to understand how it works...!

Re: turning an array of structs into a struct of arrays

2015-07-03 Thread John Colvin via Digitalmars-d-learn
On Friday, 3 July 2015 at 10:52:03 UTC, Laeeth Isharc wrote: I have an array of structs eg struct PriceBar { DateTime date; double open; double high; double low; double close; } (which fields are present in this particular struct will depend on template arguments). what is the

Re: turning an array of structs into a struct of arrays

2015-07-03 Thread Babu via Digitalmars-d-learn
On Friday, 3 July 2015 at 10:52:03 UTC, Laeeth Isharc wrote: I have an array of structs eg struct PriceBar { DateTime date; double open; double high; double low; double close; } (which fields are present in this particular struct will depend on template arguments). what is the

turning an array of structs into a struct of arrays

2015-07-03 Thread Laeeth Isharc via Digitalmars-d-learn
I have an array of structs eg struct PriceBar { DateTime date; double open; double high; double low; double close; } (which fields are present in this particular struct will depend on template arguments). what is the best way to turn these at compile time into a struct of arrays?

Re: turning an array of structs into a struct of arrays

2015-07-03 Thread Laeeth Isharc via Digitalmars-d-learn
see https://github.com/economicmodeling/soa Thanks v much for this. Figured out in the meantime one solution here (probably quite ugly): https://gist.github.com/Laeeth/9174498f9b79dc90ac18