Merge remote-tracking branch 'retro-retro'
This commit is contained in:
commit
ee8b7ef719
@ -408,22 +408,8 @@ if (isInputRange!R)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Reverse-access-order range returned by `retro`.
|
||||||
* Iterates a bidirectional range backwards.
|
private struct Retro(Range)
|
||||||
*
|
|
||||||
* If $(D_PARAM Range) is a random-access range as well, the resulting range
|
|
||||||
* is a random-access range too.
|
|
||||||
*
|
|
||||||
* Params:
|
|
||||||
* Range = Bidirectional range type.
|
|
||||||
* range = Bidirectional range.
|
|
||||||
*
|
|
||||||
* Returns: Bidirectional range with the elements order reversed.
|
|
||||||
*/
|
|
||||||
auto retro(Range)(Range range)
|
|
||||||
if (isBidirectionalRange!Range)
|
|
||||||
{
|
|
||||||
static struct Retro
|
|
||||||
{
|
{
|
||||||
Range source;
|
Range source;
|
||||||
|
|
||||||
@ -526,9 +512,30 @@ if (isBidirectionalRange!Range)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version (unittest) static assert(isBidirectionalRange!Retro);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Retro(range);
|
/**
|
||||||
|
* Iterates a bidirectional range backwards.
|
||||||
|
*
|
||||||
|
* If $(D_PARAM Range) is a random-access range as well, the resulting range
|
||||||
|
* is a random-access range too.
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
* Range = Bidirectional range type.
|
||||||
|
* range = Bidirectional range.
|
||||||
|
*
|
||||||
|
* Returns: Bidirectional range with the elements order reversed.
|
||||||
|
*/
|
||||||
|
auto retro(Range)(return Range range)
|
||||||
|
if (isBidirectionalRange!Range)
|
||||||
|
{
|
||||||
|
// Special case: retro(retro(range)) is range
|
||||||
|
static if (is(Range == Retro!RRange, RRange))
|
||||||
|
return range.source;
|
||||||
|
else
|
||||||
|
return Retro!Range(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user