On 12/10/10 7:04 PM, Craig Black wrote:

This concerns a decision not yet firmed-up on whether objects should
be cheap to copy or not.

What happens is that sort wants to swap elements at given indices.
Your opIndex, I assume, returns by value. (If it returned by reference
you'd have no problem sorting.) Then sort makes a number of heroic
attempts at figuring out how to swap elements in your range (e.g. by
trying moveAt()) before failing in frustration.

If we mandate cheap copy, then swap via two copies should be fine,
which simplifies implementation a great deal and also your life as a
user of it. We haven't made that decision yet. There is the concern
that things would become too inefficient.


Andrei

Thanks for the response. I appreciate the emphasis on efficiency.

But my opIndex does return a reference:
ref T opIndex(int i) { ... }

In that case please send me the code so I can take a look.

Thanks,

Andrei

Reply via email to