[Issue 16033] std.algorithm.sorting.sort should be possible with const/immutable object

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 17 06:09:27 PDT 2016


ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g at gmail.com ---
> In my understanding elements can be immutable and const, but assigning
> elements isn't. So shouldn't it be possible to use emplace to swap them
> around?

Swapping stuff around means writing (to both locations). But you can't
overwrite immutable data, and you can't write through a const reference. So no,
you can't swap const or immutable elements. Doing so would break the guarantees
that const and immutable give.

Closing as invalid. Please reopen if I'm missing something. Or maybe make a
thread on D.learn if the details of immutable and const are not clear.


More information about the Digitalmars-d-bugs mailing list