Share via


forward_list::insert_after

Adds elements to the forward list after a specified position.

iterator insert_after(const_iterator _Where, const Type& _Val);
void insert_after(const_iterator _Where, size_type _Count, const Type& _Val);
template<class InputIterator>
    void insert_after(const_iterator _Where, InputIterator _First,
    InputIterator _Last);
void insert_after(const iterator _Where,
    initializer_list<Type> _IList);
iterator insert_after(const_iterator _Where, Type&& _Val);

Parameters

Parameter

Description

_Where

The position in the target forward list where the first element is inserted.

_Count

The number of elements to insert.

_First

The beginning of the insertion range.

_Last

The end of the insertion range.

_Val

The element added to the forward list.

_IList

A brace-enclosed initializer list, which behaves just like a sequence of elements of type _Ty.

Return Value

An iterator that designates the newly inserted element (first and last member functions only).

Remarks

Each of the member functions inserts, just after the element pointed to by _Where in the controlled sequence, a sequence specified by the remaining operands.

The first member function inserts a single element with value _Val and returns an iterator that designates the newly inserted element.

The second member function inserts a repetition of _Count elements of value _Val.

If InputIterator is an integer type, the third member function behaves the same as insert(it, (size_type)_First, (Type)_Last). Otherwise, it inserts the sequence [_First, _Last), which must not overlap the initial controlled sequence.

The fourth member function inserts the sequence specified by an object of class initializer_list<Type>.

The last member function is the same as the first, but with an rvalue reference.

Inserting N elements causes N constructor calls. Reallocation occurs, but no iterators or references become invalid.

If an exception is thrown during the insertion of one or more elements, the container is left unaltered and the exception is rethrown.

Requirements

Header: <forward_list>

Namespace: std

See Also

Reference

forward_list Class