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 an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
flatten
Description

Returns a new sequence without nested sequences.

Synopsis
template<
    typename Sequence
    >
typename result_of::flatten<Sequence>::type flatten(Sequence& seq);

template<
    typename Sequence
    >
typename result_of::flatten<Sequence const>::type flatten(Sequence const& seq);

Table 1.86. Parameters

Parameter

Requirement

Description

seq

A model of Forward Sequence

Operation's argument


Expression Semantics
flatten(seq);

Return type:

Semantics: Returns a new sequence containing all the leaf elements of seq.

Complexity

Constant. Returns a view which is lazily evaluated.

Header
#include <boost/fusion/algorithm/transformation/flatten.hpp>
#include <boost/fusion/include/flatten.hpp>
Example
const vector<int, int, vector<int, int>, int> vec(1, 2, make_vector(3, 4), 5);
assert(flatten(vec) == make_vector(1, 2, 3, 4, 5)));

PrevUpHomeNext