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
erase
Description

Returns a new sequence, containing all the elements of the original except those at a specified iterator, or between two iterators.

Synopsis
template<
    typename Sequence,
    typename First
    >
typename result_of::erase<Sequence const, First>::type erase(
    Sequence const& seq, First const& it1);

template<
    typename Sequence,
    typename First,
    typename Last
    >
typename result_of::erase<Sequence const, First, Last>::type erase(
    Sequence const& seq, First const& it1, Last const& it2);

Table 1.76. Parameters

Parameters

Requirement

Description

seq

A model of Forward Sequence

Operation's argument

it1

A model of Forward Iterator

Iterator into seq

it2

A model of Forward Iterator

Iterator into seq after it1


Expression Semantics
erase(seq, pos);

Return type:

Semantics: Returns a new sequence, containing all the elements of seq except the element at pos.

erase(seq, first, last);

Return type:

Semantics: Returns a new sequence, with all the elements of seq, in their original order, except those in the range [first,last).

Complexity

Constant. Returns a view which is lazily evaluated.

Header
#include <boost/fusion/algorithm/transformation/erase.hpp>
#include <boost/fusion/include/erase.hpp>
Example
const vector<int, double, char> vec(1, 2.0, 'c');
assert(erase(vec, next(begin(vec))) == make_vector(1, 'c'));
assert(erase(vec, next(begin(vec)), end(vec)) == make_vector(1));

PrevUpHomeNext