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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 17 04:54:58 PDT 2016


          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: nobody at puremagic.com
          Reporter: greensunny12 at gmail.com

The following yields:

void main()
    import std.algorithm.sorting : sort;
    const(int)[] arr = [1, 2, 3];

foo.d(6): Error: template std.algorithm.sorting.sort cannot deduce function
from argument types !()(const(int)[]), candidates are:
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?


More information about the Digitalmars-d-bugs mailing list