Re: Enumerating structs?

2012-01-04 Thread Heywood Floyd
Yeah, D feels like that to me too, sometimes. Anyways, for your question - would using the struct name be good enough? They're easy to get hold of and usable in switch statements. If not, how about this: import std.typetuple; struct TypeEnum( T... ) { static pure nothrow @property

Enumerating structs?

2012-01-03 Thread Heywood Floyd
Hello! I have some structs struct A { int a; } struct B { int b, c; } and I'd like to be able to enumerate them (preferrably as integers) based on their names. I've no idea how this would look, but some pseudo code that would use this feature: // pseudo int type = stream.read!int();

Re: Enumerating structs?

2012-01-03 Thread Simen Kjærås
On Tue, 03 Jan 2012 16:35:29 +0100, Heywood Floyd soul...@gmail.com wrote: Hello! I have some structs struct A { int a; } struct B { int b, c; } and I'd like to be able to enumerate them (preferrably as integers) based on their names. I've no idea how this would look, but some