Trass3r wrote: > BCS schrieb: >> Reply to Lutger, >> >>> Another possible hack: if used from a >>> different module, you could use the 'compiles' trait with allMembers >>> to find out if a member can be accessed. >>> >> >> you could define a template in another module that does the check and >> returns the result. >> >> > > Well, it'd indeed be used from a different module than class, in fact > from a different package. > But this only gives the public members, right?
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