Tuples and compile-time assigned properties

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Sep 19 08:22:29 PDT 2013


On 19/09/13 16:55, Artur Skawina wrote:
> I'm not sure i understand your problem, but you could use structs. ie:
>
>     struct VertexProperties {
>        size_t color;
>        string name;
>     }
>
> You can get the field names and types at CT and work with that.

Yes, that's a good suggestion.  I guess I was thinking that it'd be easier to do 
something like

     auto g = Graph!(Tuple!(double, "weight"), Tuple!(size_t, "colour", string, 
"name"));

... than to force the user to define a struct up front and pass it as template 
parameter.


More information about the Digitalmars-d-learn mailing list