Defined in: <forward_list>
Note, this article is not finished! You can help by editing this doc page.
Overview
- Simplified (since C++11)
- Detailed
template< class T, /* .. */ >
class forward_list;
- Regular (since C++11)
- Polymorphic (since C++17)
template<
class T,
class Allocator = std::allocator<T>
> class forward_list;
namespace pmr {
template< class T >
using forward_list = std::forward_list<T, std::pmr::polymorphic_allocator<T>>;
}
Forward list is a container that supports fast insertion and removal of elements from anywhere in the container.
Technical definition of a forward list
std::forward_list
Defined in | forward_list |
Template parameters
See technical details for more detailed information.
pub | T | Type of the elements. |
pub | Allocator | Allocator that is used to acquire/release memory and to construct/destroy the elements in that memory. |
Type names
pub | value_type | T |
pub | allocator_type | Allocator |
pub | size_type | Unsigned integer type (usually std::size_t ) |
pub | difference_type | Signed integer type (usually std::ptrdiff_t ) |
pub | reference | value_type& |
pub | const_reference | value_type const& |
pub | pointer | Allocator::pointer (until C++11)std::allocator_traits<Allocator>::pointer (since C++11) |
pub | const_pointer | Allocator::const_pointer (until C++11)std::allocator_traits<Allocator>::const_pointer (since C++11) |
pub | iterator |
|
pub | const_iterator |
|
Member functions
pub | (constructors) | Constructs a vector. |
pub | (destructor) | Destroys the vector, deallocating internal storage if used. |
pub | operator= | Assigns values to the container. |
pub | assign | Assigns values to the container. |
pub | get_allocator | Returns the associated allocator. |
Element access
pub | front | Access the first element. |
Iterators
pub | before_begin cbefore_begin | Returns an |
pub | begin cbegin | Returns an |
pub | end cend | Returns an |
Capacity
pub | empty | Returns |
pub | max_size | Returns the maximum possible number of elements. |
Modifiers
pub | clear | Clears the contents. |
pub | insert_after | Inserts elements after the elements. |
pub | emplace_after | Constructs elements in-place after an element. |
pub | erase_after | Erases an element after an element. |
pub | push_front | Inserts an element to the beginning. |
pub | emplace_front | Constructs an element in-place at the beginning. |
pub | pop_front | Removes the first element. |
pub | resize | Changes the number of elements stored. |
pub | swap | Swaps the contents. |
Operations
pub | merge | Merges two sorted lists. |
pub | splice_after | Moves elements from another forward list. |
pub | remove remove_if | Removes elements satisfying specific criteria. |
pub | reverse | Reverses the order of the elements. |
pub | unique | Removes consecutive duplicate elements. |
pub | sort | Sorts the elements. |
Non-member functions
pub | operator== operator!= (removed in C++20) operator< (removed in C++20) operator> (removed in C++20) operator<= (removed in C++20) operator>= (removed in C++20) operator<=> (since C++20) | Lexicographically compares the values in the list. |
pub | std::swap (std::forward_list) | An overload for a std::swap algorithm. |
pub | erase (std::forward_list) erase_if (std::forward_list) | Overloads for std::erase/std::erase_if algorithms. |
Deduction guides (since C++17)
Click to expand
Examples
This section requires improvement. You can help by editing this doc page.
Hover to see the original license.