[Issue 9160] New: 2.061alpha multiSort no longer working with L-value only comparators

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 15 06:02:10 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9160

           Summary: 2.061alpha multiSort no longer working with L-value
                    only comparators
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-12-15 06:01:52 PST ---
Changing DMD to no longer accept struct literals as L-value as a side effect
broke template constraint in std.algorithm.multiSort:

7556: is(typeof(binaryFun!(less[0])(E.init, E.init)) == bool)

The E.init is not an L-value and thus the code below no longer works:

import std.algorithm;

struct A{
    int x;
    int y;
    //... potentially quite big struct
}

bool byX(const ref A lhs, const ref A rhs)
{
    return lhs.x < rhs.x;
}

bool byY(const ref A lhs, const ref A rhs)
{
    return lhs.y < rhs.y;
}

void main()
{
    auto points = [ A(4, 1), A(2, 4)];
    multiSort!(byX, byY)(points);
    assert(points[0] == A(2, 4));
    assert(points[1] == A(4, 1));
}

A chunk of text for this error:

multi_bug.d(22): Error: template std.algorithm.multiSort!(byX, byY).multiSort
do
es not match any function template declaration. Candidates are:
C:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7712):       
std.algorithm
.multiSort!(byX, byY).multiSort(Range)(Range r) if
(validPredicates!(ElementType
!(Range), less))
multi_bug.d(22): Error: template std.algorithm.multiSort!(byX,
byY).multiSort(Ra
nge)(Range r) if (validPredicates!(ElementType!(Range), less)) cannot deduce
tem
plate function from argument types !()(A[])

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list