Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

swap_ranges()

Library:  Algorithms


Function

Local Index

No Entries

Summary

Algorithm that exchanges a range of values in one location with those in another

Synopsis

#include <algorithm>

namespace std {
  template <class ForwardIterator1, class ForwardIterator2>
  ForwardIterator2 
  swap_ranges(ForwardIterator1 start1,
              ForwardIterator1 finish1,
              ForwardIterator2 start2);
}

Description

The swap_ranges() algorithm exchanges corresponding values in two ranges, in the following manner:

For each non-negative integer n < (finish - start), the function exchanges *(start1 + n) with *(start2 + n)). After completing all exchanges, swap_ranges() returns an iterator that points to the end of the second container (in other words, start2 + (finish1 -start1)). The result of swap_ranges() is undefined if the two ranges [start, finish) and [start2, start2 + (finish1 - start1)) overlap.

Example

See Also

iter_swap(), swap()

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 25.2.2



Previous fileTop of DocumentContentsIndex pageNext file