Javatpoint Logo
Javatpoint Logo

forward_list::emplace_front() in C++

In this article, we will discuss the forward_list::emplace_front() function in C++ with its syntax and examples.

In C++ STL, a forward list implements a single linked list. The forward list, introduced in C++11, is more helpful than other types of containers for insertion, deletion, and moving operations (such as sort) since it allows for time-constant insertion and removal of entries. The forward list varies from the list in that it simply maintains track of the location of the next element, whereas the list keeps track of both the next and previous entries.


It has the following syntax:

The function above is used for putting a new element into the forward-looking list container, adding the new element to the starting point of the forward list.


Parameters: The value of a parameter is the object to be added to the forward list.

Result: The argument is appended at the start of the forward list.


Exceptions and Errors

  1. It provides a strong exception assurance, so if an exception is thrown, no modifications are made.
  2. The argument must be of the same type as the container, and an error will be generated.

Example 1:

Filename: forward.cpp


13 12 11 10 9 8

Example 2:

Filename: ForwardInt.cpp


Programming Languages Standards

Example 3:

Filename: ForwardList.cpp


j k l m n

Example 4:

Filename: forwardApplication.cpp


21 27 32 43 45 93

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA