Bug 10460 – std.algorithm: some of algorithms don't use 'auto ref' for front

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-24T04:16:00Z
Last change time
2014-08-29T20:55:39Z
Assigned to
nobody
Creator
lomereiter

Comments

Comment #0 by lomereiter — 2013-06-24T04:16:05Z
The following should use 'auto ref': Until, SetDifference, SetSymmetricDifference, SetIntersection, SetUnion (sorry, I'm too lazy to make a pull request...)
Comment #1 by peter.alexander.au — 2014-08-19T21:07:52Z
SetIntersection and SetUnion may be confusing to return auto ref since they contain overlap, e.g. int[] a = [1, 2, 3]; int[] b = [2, 3, 4]; foreach (ref e; setIntersection(a, b)) e = 0; Does this change the elements of 'a' or 'b'? For the difference ones, it makes sense because the element is only in one of the sets.
Comment #2 by github-bugzilla — 2014-08-29T20:55:38Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/5e0532b9e7d0a67567db0c7c9a3b541c829c75ed Fix Issue 10460 - auto ref for Union, SetDifference, SetSymmetricDifference https://issues.dlang.org/show_bug.cgi?id=10460 The rearrangement of SetSymmetricDifference.front was needed since auto ref doesn't deduce correctly when there are multiple return statements (by design), so a single return statement with the ternary operator was used. https://github.com/D-Programming-Language/phobos/commit/b61d9fa6844632ced1758f75ba2812c057d34bb8 Merge pull request #2461 from fb-pja/bug10460 Fix Issue 10460 - auto ref Union, SetDifference, SetSymmetricDifference