Back to Arangodb

erase

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/erase.html

3.12.9.14.5 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Sequences / Intrinsic Metafunctions / erase |

erase

Synopsis

template<
      typename Sequence
    , typename First
    , typename Last =_unspecified_>
struct[erase](./erase.html){
    typedef_unspecified_type;
};

Description

erase performs a removal of one or more adjacent elements in the sequence starting from an arbitrary position.

#include <[boost/mpl/erase.hpp](../../../../boost/mpl/erase.hpp)>

Model of

Tag Dispatched Metafunction

Parameters

ParameterRequirementDescription
SequenceExtensible Sequence or Extensible Associative SequenceA sequence to erase from.
FirstForward IteratorAn iterator to the beginning of the range to be erased.
LastForward IteratorAn iterator past-the-end of the range to be erased.

Expression semantics

For any Extensible Sequence s, and iterators pos, first and last into s:

typedef[erase](./erase.html)<s,first,last>::type r;

| Return type: |

Extensible Sequence.

| | Precondition: |

[first,last) is a valid range in s.

| | Semantics: |

r is a new sequence, concept-identical to s, of the following elements: [begin<s>::type, pos), [last, end<s>::type).

| | Postcondition: |

The relative order of the elements in r is the same as in s;

[size](./size.html)<r>::value ==[size](./size.html)<s>::value -[distance](./distance.html)<first,last>::value

|

typedef[erase](./erase.html)<s,pos>::type r;

| Return type: |

Extensible Sequence.

| | Precondition: |

pos is a dereferenceable iterator in s.

| | Semantics: |

Equivalent to

typedef[erase](./erase.html)< s,pos,[next](./next.html)<pos>::type >::type r;

|

For any Extensible Associative Sequence s, and iterator pos into s:

typedef[erase](./erase.html)<s,pos>::type r;

| Return type: | Extensible Sequence. | | Precondition: | pos is a dereferenceable iterator to s. | | Semantics: | Erases the element at a specific position pos; equivalent to erase_key<s, deref<pos>::type >::type. | | Postcondition: | size<r>::value == size<s>::value - 1. |

Complexity

Sequence archetypeComplexity (the range form)
Extensible Associative SequenceAmortized constant time.
Extensible SequenceQuadratic in the worst case, linear at best.

Example

typedef[vector\_c](./vector-c.html)<int,1,0,5,1,7,5,0,5> values;
typedef[find](./find.html)< values,[integral\_c](./integral-c.html)<int,7> >::type pos;
typedef[erase](./erase.html)<values,pos>::type result;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)([size](./size.html)<result>::value, ==, 7 );

typedef[find](./find.html)<result,[integral\_c](./integral-c.html)<int,7> >::type iter;[BOOST\_MPL\_ASSERT](./assert.html)(( is_same< iter,[end](./end.html)<result>::type > ));

See also

Extensible Sequence, Extensible Associative Sequence, erase_key, pop_front, pop_back, insert

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |