Bug 5611 – back() and front() with ref return + opSlice() in sort() constraint
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-02-19T07:23:00Z
Last change time
2013-12-27T11:18:17Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2011-02-19T07:23:14Z
With some experiments I have seen that the input of std.algorithm.sort() has other requirements beside being just a random access range (dmd 2.052):
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=24795
My experiment shows that beside being a random access range, the input range needs also:
- opSlice()
- back() and front() must return their results by ref.
So to reduce troubles for the users I suggest to add those three requirements inside the template constraint of sort(), to produce a better error message and detect problems more early.
Comment #1 by xinok — 2013-12-27T11:18:17Z
Since this bug report was filed, the sorting algorithms were updated and the template restraints were updated to reflect these changes.