loop through specific class members
    Daniel Keep 
    daniel.keep.lists at gmail.com
       
    Mon Jan 19 15:58:08 PST 2009
    
    
  
BCS wrote:
> Reply to Daniel,
> 
> 
>> It depends on what exactly you're trying to do.  Some time ago, I
>> wrote a library that created XML loaders for structs, and it needed to
>> know the names of fields.  Pre-traits, this is what I used:
>>
>> struct Stuff
>> {
>> int foo;
>> char[] bar;
>> alias Tuple!("foo", "bar") _fields;
>> }
>> Then I just looped over _fields.
>>
>> -- Daniel
>>
> 
> you can get the names even in D1.0. Not exactly clean but...
> 
> http://codepad.org/Eu16XqFu
I remember trying that, but abandoning it for some reason.  This code is
getting old now; over two years now, so that might not have worked back
then.
  -- Daniel
    
    
More information about the Digitalmars-d-learn
mailing list