Inserts a new element at the beginning of the forward_list, right before its current first element. The content of val is copied (or moved) to the inserted element.

This effectively increases the container size by one.

A similar member function exists, emplace_front, which constructs the inserted element object directly in place, without performing any copy or move operation.

Parameters

val

Value to be copied (or moved) to the inserted element.
Member type value_type is the type of the elements in the container, defined in forward_list as an alias of its first template parameter (T).

Return value

none

If storage is needed for the new element, it is allocated using allocator_traits<allocator_type>::construct(), which may throw exceptions on failure (for the default allocator, bad_alloc is thrown if the allocation request does not succeed).