mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 16:10:45 +03:00
.init value of cartesianProduct should be empty.
This commit is contained in:
parent
6e51fdf469
commit
5f0155b0c8
1 changed files with 10 additions and 1 deletions
|
@ -12996,11 +12996,12 @@ auto cartesianProduct(RR...)(RR ranges)
|
|||
{
|
||||
RR ranges;
|
||||
RR current;
|
||||
bool empty = false;
|
||||
bool empty = true;
|
||||
|
||||
this(RR _ranges)
|
||||
{
|
||||
ranges = _ranges;
|
||||
empty = false;
|
||||
foreach (i, r; ranges)
|
||||
{
|
||||
current[i] = r.save;
|
||||
|
@ -13058,6 +13059,14 @@ unittest
|
|||
foreach (_; cprod2) {} // should not crash
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
// .init value of cartesianProduct should be empty
|
||||
auto cprod = cartesianProduct([0,0], [1,1], [2,2]);
|
||||
assert(!cprod.empty);
|
||||
assert(cprod.init.empty);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
auto cartesianProduct(R1, R2, RR...)(R1 range1, R2 range2, RR otherRanges)
|
||||
if (!allSatisfy!(isForwardRange, R1, R2, RR) ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue