finding composed structs

Tobias Pankrath tobias at pankrath.net
Tue Oct 30 13:17:06 PDT 2012


On Tuesday, 30 October 2012 at 20:16:12 UTC, Tobias Pankrath
wrote:

>
> In the meantime you can use this function template to compare 
> structs field by field.
>
> bool oneStepEqual(T,F)(ref T lhs, ref F rhs)
>     if(is(Unqual!T == Unqual!F) && is(T == struct))
> {
>         bool result = true;
>     foreach(mem; __traits(allMembers, T))
>     {
>         static if(!is(typeof(__traits(getMember, T, mem)) == 
> function))
>         {
>             result = result && (__traits(getMember, lhs, mem) 
> == __traits(getMember, rhs, mem));
>         }
>     }
>     return result;
> }

Beautiful version: http://dpaste.dzfl.pl/2340d73f


More information about the Digitalmars-d-learn mailing list