Tuples and compile-time assigned properties
Artur Skawina
art.08.09 at gmail.com
Thu Sep 19 07:55:57 PDT 2013
On 09/19/13 16:40, Joseph Rushton Wakeling wrote:
> alias EdgeProperties = Tuple!(double, "weight");
>
> alias VertexProperties = Tuple!(size_t, "colour", string, "name");
>
> So then, you'd be able to extract the list of variable names and types at compile time and use them to create the underlying data structures required; and similarly you'd be able to create a set of public interfaces that gives you access to those members.
>
> With that in mind, there are a number of potential issues that arise:
>
> (i) is there a compile-time constraint via which I can insist that every
> member of the tuple must be named?
>
> (ii) is there an easy way to extract all the names of tuple members as an
> array of strings?
>
> Can anyone advise?
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.
artur
More information about the Digitalmars-d-learn
mailing list