Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit c89e626766.
PrevUpHomeNext
swap
Description

Performs an element by element swap of the elements in 2 sequences.

Synopsis
template<typename Seq1, typename Seq2>
typename result_of::swap<Seq1, Seq2>::type
swap(Seq1& seq1, Seq2& seq2);
Parameters

Parameters

Requirement

Description

seq1, seq2

Models of Forward Sequence

The sequences whose elements we wish to swap.

Expression Semantics
swap(seq1, seq2);

Return type: void

Precondition: size(seq1) == size(seq2)

Semantics: Calls swap(a1, b1) for corresponding elements in seq1 and seq2.

Header
#include <boost/fusion/sequence/intrinsic/swap.hpp>
#include <boost/fusion/include/swap.hpp>
Example
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"));

PrevUpHomeNext