iterate traits ?

2014-08-19 Thread ddos via Digitalmars-d-learn
Hi, i'm trying to create a dynamic vertex format for opengl, defined at compiletime by a struct e.g. struct Vertex {float[3] position, float[3] normal} i can get the name of all members with this: auto b = [ __traits(allMembers, VertexType) ]; but i can't iterate them at compiletime because

Re: iterate traits ?

2014-08-19 Thread Justin Whear via Digitalmars-d-learn
On Tue, 19 Aug 2014 18:15:33 +, ddos wrote: since i need to setup vertexpointers for opengl at runtime my next question? - is it possible to evaluate the traits also at runtime? but i'd also like to know how i can iterate them at compiletime thx in advance :) Take a look at this

Re: iterate traits ?

2014-08-19 Thread ddos via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 18:25:24 UTC, Justin Whear wrote: On Tue, 19 Aug 2014 18:15:33 +, ddos wrote: since i need to setup vertexpointers for opengl at runtime my next question? - is it possible to evaluate the traits also at runtime? but i'd also like to know how i can iterate

Re: iterate traits ?

2014-08-19 Thread Philippe Sigaud via Digitalmars-d-learn
A foreach becomes compile-time whenever the aggregate is a purely compile- time construct such as a tuple. Yeah, I think you transformed it into a runtime array by using [ ... ]. Tuples with compatible types can be 'downgraded' to arrays that way. But there is no need to: tuples are iterable,