[Issue 1309] sorting arrays of structs is broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 28 11:16:55 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1309





------- Comment #2 from wbaxter at gmail.com  2008-11-28 13:16 -------
(In reply to comment #1)
> Just a stab in the dark, but you might try making the argument to opCmp 'const
> MyStruct' or 'const MyStruct*'.  An opCmp shouldn't generally modify its
> argument so maybe DMD expects a 'const' in the signature.
> 

Actually, if the above hypothesis is true, then probably 'this' should be
const, too:
  int opCmp(const MyStruct x) const { ... }
(if that's how you make this constant in D2 these days...}

There might be another problem, though, with the most recent D2, since 'this'
is now a reference.  As mentioned in bug 1861, using ref arguments in your
opCmp never worked with .sort, this might affect D2 now that this is a
reference.


-- 



More information about the Digitalmars-d-bugs mailing list