structs, templates, alias

Robert Clipsham robert at octarineparrot.com
Sun Apr 25 10:26:47 PDT 2010


On 25/04/10 16:04, Ellery Newcomer wrote:
> Does anyone have any ideas regarding this problem?

I haven't looked into this fully, but for the "the length field and the 
array/structure are separated by one or more fields" issue, something 
like this should help:
----
foreach( m; MyStruct.tupleof )
{
   static if( is( typeof(m) x : x[] ) )
   {
     // This member is an array, so read the size_t length first, then
     // the elements
   }
   else
   {
     // Treat normally.
   }
}
----

I don't think there's a way of finding if a member is part of an 
anonymous union, the only way around this seems to be to use a named 
union so it is treated as one field.


More information about the Digitalmars-d-learn mailing list