setIntersection of struct range

Jesse Phillips jessekphillips+d at gmail.com
Wed Aug 12 13:38:03 PDT 2009


Jesse Phillips Wrote:

> Steven Schveighoffer Wrote:
> 
> > You did not define a way to compare two S structs.  Try redefining S like  
> > this:
> > 
> > struct S {
> >    string label;
> >    int opCmp(ref const S s2) const {
> >       if(label < s2.label)
> >         return -1;
> >       if(label > s2.label)
> >         return 1;
> >       return 0;
> >    }
> > }
> 
> You know, I didn't think about this because struct arrays are sorted by the first element if you do array.sort. But this does make the error a little more clear.

Got around to trying this, but it didn't fix the problem.


More information about the Digitalmars-d-learn mailing list