Skip to content

Commit 759da8e

Browse files
committed
swapRanges: Remove redundant constraint tests
hasSwappableElements already tests for isInputRange. Also fix hasSwappableElements docs.
1 parent 1951dec commit 759da8e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

std/algorithm/mutation.d

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,9 +2728,8 @@ Returns:
27282728
*/
27292729
Tuple!(InputRange1, InputRange2)
27302730
swapRanges(InputRange1, InputRange2)(InputRange1 r1, InputRange2 r2)
2731-
if (isInputRange!(InputRange1) && isInputRange!(InputRange2)
2732-
&& hasSwappableElements!(InputRange1) && hasSwappableElements!(InputRange2)
2733-
&& is(ElementType!(InputRange1) == ElementType!(InputRange2)))
2731+
if (hasSwappableElements!InputRange1 && hasSwappableElements!InputRange2
2732+
&& is(ElementType!InputRange1 == ElementType!InputRange2))
27342733
{
27352734
for (; !r1.empty && !r2.empty; r1.popFront(), r2.popFront())
27362735
{

std/range/primitives.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ R r;
12611261
static assert(isInputRange!R);
12621262
swap(r.front, r.front);
12631263
static if (isBidirectionalRange!R) swap(r.back, r.front);
1264-
static if (isRandomAccessRange!R) swap(r[], r.front);
1264+
static if (isRandomAccessRange!R) swap(r[0], r.front);
12651265
----
12661266
*/
12671267
template hasSwappableElements(R)

0 commit comments

Comments
 (0)