C++ Deque emplace_front function adds a new element to the beginning of the deque container and the size of the container is increased by one.
Syntax
Example
void emplace_front(value_type val);
Parameter
val : New value is to be inserted at the beginning of the deque.
Return value
It does not return any value.
Example 1
Let's see a simple example
Example
#include <iostream>
#include<deque>
using namespace std;
int main()
{
deque<string> fruit={"mango","banana"};
deque<string>::iterator itr;
fruit.emplace_front("apple");
fruit.emplace_front("strawberry");
for(itr=fruit.begin();itr!=fruit.end();++itr)
std::cout << *itr<<" ";
return 0;
}
Output:
Output
strawberry apple mango banana
In this example, emplace_front function add two strings i.e apple and strawberry at the beginning of the deque.