https://issues.dlang.org/show_bug.cgi?id=16033
Issue ID: 16033 Summary: std.algorithm.sorting.sort should be possible with const/immutable object Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: greensunn...@gmail.com The following yields: void main() { import std.algorithm.sorting : sort; const(int)[] arr = [1, 2, 3]; arr.sort(); } foo.d(6): Error: template std.algorithm.sorting.sort cannot deduce function from argument types !()(const(int)[]), candidates are: /usr/include/dlang/dmd/std/algorithm/sorting.d(1027): std.algorithm.sorting.sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r) if ((ss == SwapStrategy.unstable && (hasSwappableElements!Range || hasAssignableElements!Range) || ss != SwapStrategy.unstable && hasAssignableElements!Range) && isRandomAccessRange!Range && hasSlicing!Range && hasLength!Range) 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? --