diff --git a/octa/algorithm.h b/octa/algorithm.h index 3d58c07..15614a6 100644 --- a/octa/algorithm.h +++ b/octa/algorithm.h @@ -366,12 +366,13 @@ namespace octa { } template - R2 swap_ranges(R1 range1, R2 range2) { - for (; !range1.empty(); range1.pop_first()) { + Pair swap_ranges(R1 range1, R2 range2) { + while (!range1.empty() && !range2.empty()) { swap(range1.first(), range2.first()); + range1.pop_first(); range2.pop_first(); } - return range2; + return Pair(range1, range2); } template