[Issue 21183] New: schwartzSort does not strip const
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Aug 21 10:28:40 UTC 2020
    
    
  
https://issues.dlang.org/show_bug.cgi?id=21183
          Issue ID: 21183
           Summary: schwartzSort does not strip const
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de
Consider the following code:
import std.algorithm : schwartzSort;
import std.array : array;
struct S
{
    int i;
    const(int) foo() { return i; }
}
void main()
{
    auto list = [S(4), S(3), S(2)];
    assert(list.dup.schwartzSort!(a => a.foo).array == [S(2), S(3), S(4)]);
}
This leads to cryptic errors due to the fact that `schwartzSort` does not strip
the `const` from `const(int)` for its internal array, even though it trivially
could since it's a value type.
--
    
    
More information about the Digitalmars-d-bugs
mailing list