mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 22:50:38 +03:00
Merge pull request #49 from kyllingstad/joiner-input-range
std.algorithm.joiner() should only require an input range
This commit is contained in:
commit
d1d81245ea
1 changed files with 8 additions and 1 deletions
|
@ -2159,7 +2159,7 @@ assert(equal(joiner(["Mary", "has", "a", "little", "lamb"], "..."),
|
||||||
----
|
----
|
||||||
*/
|
*/
|
||||||
auto joiner(RoR, Separator)(RoR r, Separator sep)
|
auto joiner(RoR, Separator)(RoR r, Separator sep)
|
||||||
if (isForwardRange!RoR && isInputRange!(ElementType!RoR)
|
if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
||||||
&& isForwardRange!Separator
|
&& isForwardRange!Separator
|
||||||
&& is(ElementType!Separator : ElementType!(ElementType!RoR)))
|
&& is(ElementType!Separator : ElementType!(ElementType!RoR)))
|
||||||
{
|
{
|
||||||
|
@ -2289,6 +2289,13 @@ unittest
|
||||||
"Mary...has...a...little...lamb"));
|
"Mary...has...a...little...lamb"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
// joiner() should work for non-forward ranges too.
|
||||||
|
InputRange!string r = inputRangeObject(["abc", "def"]);
|
||||||
|
assert (equal(joiner(r, "xyz"), "abcxyzdef"));
|
||||||
|
}
|
||||||
|
|
||||||
auto joiner(RoR)(RoR r)
|
auto joiner(RoR)(RoR r)
|
||||||
if (isInputRange!RoR && isInputRange!(ElementType!RoR))
|
if (isInputRange!RoR && isInputRange!(ElementType!RoR))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue