Bug 9160 – 2.061alpha multiSort no longer working with L-value only comparators

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-15T06:01:00Z
Last change time
2012-12-16T18:29:36Z
Keywords
pull
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2012-12-15T06:01:52Z
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[])
Comment #1 by dmitry.olsh — 2012-12-15T06:15:12Z
Comment #2 by github-bugzilla — 2012-12-16T17:34:19Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/bde7cbad4dc1effa5ca2c23459b63717246244aa fix issue 9160 multiSort constraint bug https://github.com/D-Programming-Language/phobos/commit/194ca0780390b2949cba95cea118d4833b5f39c6 Merge pull request #1011 from blackwhale/fix-multisort fix issue 9160 multiSort constraint regression