Javatpoint Logo
Javatpoint Logo

C++ Deque erase()

C++ Deque erase() function removes the element from the specified position or range and this effectively reduces the size of the deque by the number of elements removed.



pos: It defines the position at which the element to be removed from the deque.

(first,last): It defines the range within deque between which the elements to be removed.

Return value

It returns an iterator pointing to the element that followed the last element removed by the function.

Example 1

Let's see a simple example when element is removed within a range.


Content of deque:1 2 3 4 
After erasing second and third element,Content of deque:1 3 4 

Example 2

Let's see a simple example when the element is removed at the specified position


Content of deque:mango ,apple ,strawberry ,kiwi ,
Now,Content of deque:mango ,apple ,kiwi ,

Next TopicC++ Deque

Help Others, Please Share

facebook twitter pinterest