...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>
typename result_of::swap
<Seq1, Seq2>::type
swap(Seq1& seq1, Seq2& seq2);
Parameters |
Requirement |
Description |
---|---|---|
|
Models of Forward Sequence |
The sequences whose 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
.
#include <boost/fusion/sequence/intrinsic/swap.hpp> #include <boost/fusion/include/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"));