Re: Array initialization with Struct templates

2015-08-31 Thread Ali Çehreli via Digitalmars-d-learn
On 08/31/2015 08:55 PM, WhatMeWorry wrote: > Thanks for all the above suggestions, but after many hour of re-reading > Ali's book on template, structs, and mixins, I still in the woods. I've > tried two approaches: > > Templatetized struct > > st

Re: Array initialization with Struct templates

2015-08-31 Thread WhatMeWorry via Digitalmars-d-learn
Thanks for all the above suggestions, but after many hour of re-reading Ali's book on template, structs, and mixins, I still in the woods. I've tried two approaches: Templatetized struct struct Chameleon(T, Purpose p) { static if (p == P

Re: Array initialization with Struct templates

2015-08-31 Thread Daniel N via Digitalmars-d-learn
On Monday, 31 August 2015 at 05:38:54 UTC, Jonathan M Davis wrote: So, you're going to need to pass it a Chameleon!(float, purpose.POSITIONAL) and a Chameleon!(float, purpose.COLOR_ONLY color), not 6 doubles - either that, or you're going to need to declare a constructor for VertexData which ta

Re: Array initialization with Struct templates

2015-08-31 Thread Mike Parker via Digitalmars-d-learn
On Monday, 31 August 2015 at 05:47:31 UTC, Ali Çehreli wrote: On 08/30/2015 10:38 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, August 31, 2015 04:57:05 WhatMeWorry via Digitalmars-d-learn wrote: This seemingly trivial array initialization has caused me hours of grief. enum

Re: Array initialization with Struct templates

2015-08-30 Thread Ali Çehreli via Digitalmars-d-learn
On 08/30/2015 10:38 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, August 31, 2015 04:57:05 WhatMeWorry via Digitalmars-d-learn wrote: This seemingly trivial array initialization has caused me hours of grief. enum Purpose { POSITIONAL, COLOR_ONLY, COLOR_AND_ALPHA, GENERIC_TRIPL

Re: Array initialization with Struct templates

2015-08-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 31, 2015 04:57:05 WhatMeWorry via Digitalmars-d-learn wrote: > > This seemingly trivial array initialization has caused me hours > of grief. > > enum Purpose { POSITIONAL, COLOR_ONLY, COLOR_AND_ALPHA, > GENERIC_TRIPLE, GENERIC_QUAD } > Purpose purpose; > > struct Chameleon(T, Purp

Array initialization with Struct templates

2015-08-30 Thread WhatMeWorry via Digitalmars-d-learn
This seemingly trivial array initialization has caused me hours of grief. enum Purpose { POSITIONAL, COLOR_ONLY, COLOR_AND_ALPHA, GENERIC_TRIPLE, GENERIC_QUAD } Purpose purpose; struct Chameleon(T, Purpose p) // template { static if (is (p == POSITIONAL)) { T x, y, z; } el