Javatpoint Logo
Javatpoint Logo

C++ Deque emplace()

C++ Deque emplace() function inserts a new element just before the specified position and the size of the container is increased by one.

Syntax

Parameter

position: It defines the position before which the new element is to be inserted.

val: New value which is to be inserted.

Return value

It returns an iterator to the newly constructed element.

Example 1

Let's see a simple example

Output:

1 7 8 4 5 

In this example, emplace() function inserts a new element i.e 1 in the beginning of the deque.

Example 2

Let's see a simple example

Output:

C++

In this example, emplace() function inserts a new element i.e '+' at second position.


Next TopicC++ Deque



Help Others, Please Share

facebook twitter pinterest