mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
Use new cartesianProduct implementation for 2-argument case as well.
The original implementation will now only be used when one or both the ranges is either non-forward or infinite. The new implementation is also more attribute-friendly (works with pure, nothrow, @nogc, @safe), so this also fixes issue 13091.
This commit is contained in:
parent
0fb1bee92d
commit
556ef61ef8
1 changed files with 11 additions and 1 deletions
|
@ -13308,6 +13308,8 @@ When there are more than two ranges, the above conditions apply to each
|
|||
adjacent pair of ranges.
|
||||
*/
|
||||
auto cartesianProduct(R1, R2)(R1 range1, R2 range2)
|
||||
if (!allSatisfy!(isForwardRange, R1, R2) ||
|
||||
anySatisfy!(isInfinite, R1, R2))
|
||||
{
|
||||
static if (isInfinite!R1 && isInfinite!R2)
|
||||
{
|
||||
|
@ -13536,9 +13538,17 @@ unittest
|
|||
}
|
||||
}
|
||||
|
||||
// Issue 13091
|
||||
pure nothrow @safe @nogc unittest
|
||||
{
|
||||
import std.algorithm: cartesianProduct;
|
||||
int[1] a = [1];
|
||||
foreach (t; cartesianProduct(a[], a[])) {}
|
||||
}
|
||||
|
||||
/// ditto
|
||||
auto cartesianProduct(RR...)(RR ranges)
|
||||
if (ranges.length > 2 &&
|
||||
if (ranges.length >= 2 &&
|
||||
allSatisfy!(isForwardRange, RR) &&
|
||||
!anySatisfy!(isInfinite, RR))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue