...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Performs an element by element swap of the elements in 2 sequences.
template<typename Seq1, typename Seq2> void swap(Seq1& seq1, Seq2& seq2);
Parameters |
Requirement |
Description |
---|---|---|
|
Models of Forward Sequence |
The sequences whos elements we wish to swap. |
swap(seq1, seq2);
Return type: void
Precondition: size
(seq1) == size
(seq2)
Semantics: Calls swap(a1, b1)
for corresponding elements in seq1
and seq2
.
/sequence/intrinsic/swap.hpp>
vector
<int, std::string> v1(1, "hello"), v2(2, "world"); swap(v1, v2); assert(v1 ==make_vector
(2, "world")); assert(v2 ==make_vector
(1, "hello"));