Bug 14293 – min and max with predicate

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2015-03-16T17:23:00Z
Last change time
2015-03-16T18:51:34Z
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2015-03-16T17:23:01Z
There should be overloads of min and max with a predicate, e.g. the code below chooses the shortest string out of three: string x, y; ... auto s = min!((a, b) => a.length < b.length)(x, y, "hello");
Comment #1 by andrei — 2015-03-16T17:28:53Z
Oops, sorry, I meant unary predicates (the "<" is implied): string x, y; ... auto s = min!(a => a.length)(x, y, "hello");
Comment #2 by bearophile_hugs — 2015-03-16T18:51:34Z
This is an almost five years old enhancement request of mine. *** This issue has been marked as a duplicate of issue 4705 ***