...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Returns a new sequence, containing all the elements of the original except those at a specified iterator, or between two iterators.
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.63. 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 |
erase(seq, pos);
Return type: A model of Forward Sequence.
Semantics: Returns a new sequence, containing all the elements of seq except the element at pos.
erase(seq, first, last);
Return type: A model of Forward Sequence.
Semantics: Returns a new sequence, with all the elements of seq, in their original order, except those in the range [first,last).
Constant. Returns a view which is lazily evaluated.
#include <boost/fusion/algorithm/transformation/erase.hpp> #include <boost/fusion/include/erase.hpp>
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));