opCmp with structs
Alex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Nov 7 03:48:54 PST 2015
On Saturday, 7 November 2015 at 00:19:56 UTC, Ali Çehreli wrote:
> Continuing from your hint: So, opCmp works but it is sort()
> that cannot move objects of ku around because of that immutable
> variable.
So my general question is: why immutable variables shouldn't be
able to be moved (inside an array)?
> There may be references to ku objects or its id members and
> those references may be depending on the immutability of that
> member. const and immutable members effectively make objects
> unassignable. (const part is the same in C++.)
And this is also something unexpected: yes, there may be such
references and they should stay valid of course. But why
shouldn't be a concrete collection of such references be
sortable? Why this should affect other references to the
individual 'ku' objects?
More information about the Digitalmars-d-learn
mailing list