finding composed structs
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Oct 30 14:05:02 PDT 2012
On 10/30/12 4:17 PM, Tobias Pankrath wrote:
> 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
Y u no short circuit?
Andrei
More information about the Digitalmars-d-learn
mailing list