Bug 9734 – setIntersection accepts only 2 ranges, but documentation says otherwise

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-16T03:18:00Z
Last change time
2013-12-21T23:01:20Z
Assigned to
nobody
Creator
josvanuden

Comments

Comment #0 by josvanuden — 2013-03-16T03:18:26Z
std.algorithm.setIntersection only accepts 2 ranges, although the documentation says it accepts 2 or more. There's a static assert in the code that limits the input to 2 ranges. Even the example on the webpage doesn't compile: int[] a = [ 1, 2, 4, 5, 7, 9 ]; int[] b = [ 0, 1, 2, 4, 7, 8 ]; int[] c = [ 0, 1, 4, 5, 7, 8 ]; assert(equal(setIntersection(a, a), a)); assert(equal(setIntersection(a, b), [1, 2, 4, 7][])); assert(equal(setIntersection(a, b, c), [1, 4, 7][])); (...)\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10076): Error: static assert (3u == 2u) is false (...)\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10150): instantiated from here: SetIntersection!("a < b", int[], int[], int[]) test.d(16): instantiated from here: setIntersection!("a < b", int[],int[],int[]) Whether this limitation is temporary or permanent, I think the docs should indicate that you cannot (for now) input more than 2 ranges.
Comment #1 by jens.k.mueller — 2013-05-27T03:59:31Z
I just found this out as well. Can you update the documentation?
Comment #2 by jakobovrum — 2013-12-21T23:01:20Z
(In reply to comment #0) > std.algorithm.setIntersection only accepts 2 ranges, although the documentation > says it accepts 2 or more. There's a static assert in the code that limits the > input to 2 ranges. Even the example on the webpage doesn't compile: > > int[] a = [ 1, 2, 4, 5, 7, 9 ]; > int[] b = [ 0, 1, 2, 4, 7, 8 ]; > int[] c = [ 0, 1, 4, 5, 7, 8 ]; > assert(equal(setIntersection(a, a), a)); > assert(equal(setIntersection(a, b), [1, 2, 4, 7][])); > assert(equal(setIntersection(a, b, c), [1, 4, 7][])); > > (...)\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10076): Error: static > assert (3u == 2u) is false > (...)\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10150): > instantiated from here: SetIntersection!("a < b", int[], int[], int[]) > test.d(16): instantiated from here: setIntersection!("a < b", > int[],int[],int[]) > > Whether this limitation is temporary or permanent, I think the docs should > indicate that you cannot (for now) input more than 2 ranges. https://github.com/D-Programming-Language/phobos/pull/1796