libstdc++
std::list< _Tp, _Alloc > Class Template Reference

#include <stl_list.h>

Inheritance diagram for std::list< _Tp, _Alloc >:
[legend]

Public Types

typedef _Alloc allocator_type
 
typedef _List_const_iterator< _Tp > const_iterator
 
typedef _Tp_alloc_traits::const_pointer const_pointer
 
typedef _Tp_alloc_traits::const_reference const_reference
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef ptrdiff_t difference_type
 
typedef _List_iterator< _Tp > iterator
 
typedef _Tp_alloc_traits::pointer pointer
 
typedef _Tp_alloc_traits::reference reference
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef size_t size_type
 
typedef _Tp value_type
 

Public Member Functions

 list ()=default
 
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>>
 list (_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
 
 list (const allocator_type &__a) noexcept
 
 list (const list &__x)
 
 list (const list &__x, const allocator_type &__a)
 
 list (initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
 
 list (list &&)=default
 
 list (list &&__x, const allocator_type &__a) noexcept(_Node_alloc_traits::_S_always_equal())
 
 list (size_type __n, const allocator_type &__a=allocator_type())
 
 list (size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
 
 ~list ()=default
 
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>>
void assign (_InputIterator __first, _InputIterator __last)
 
void assign (initializer_list< value_type > __l)
 
void assign (size_type __n, const value_type &__val)
 
const_reference back () const noexcept
 
reference back () noexcept
 
const_iterator begin () const noexcept
 
iterator begin () noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
void clear () noexcept
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 
template<typename... _Args>
iterator emplace (const_iterator __position, _Args &&... __args)
 
template<typename... _Args>
reference emplace_back (_Args &&... __args)
 
template<typename... _Args>
reference emplace_front (_Args &&... __args)
 
bool empty () const noexcept
 
const_iterator end () const noexcept
 
iterator end () noexcept
 
iterator erase (const_iterator __first, const_iterator __last) noexcept
 
iterator erase (const_iterator __position) noexcept
 
const_reference front () const noexcept
 
reference front () noexcept
 
allocator_type get_allocator () const noexcept
 
iterator insert (const_iterator __p, initializer_list< value_type > __l)
 
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>>
iterator insert (const_iterator __position, _InputIterator __first, _InputIterator __last)
 
iterator insert (const_iterator __position, const value_type &__x)
 
iterator insert (const_iterator __position, size_type __n, const value_type &__x)
 
iterator insert (const_iterator __position, value_type &&__x)
 
size_type max_size () const noexcept
 
void merge (list &&__x)
 
template<typename _StrictWeakOrdering >
void merge (list &&__x, _StrictWeakOrdering __comp)
 
void merge (list &__x)
 
template<typename _StrictWeakOrdering >
void merge (list &__x, _StrictWeakOrdering __comp)
 
listoperator= (const list &__x)
 
listoperator= (initializer_list< value_type > __l)
 
listoperator= (list &&__x) noexcept(_Node_alloc_traits::_S_nothrow_move())
 
void pop_back () noexcept
 
void pop_front () noexcept
 
void push_back (const value_type &__x)
 
void push_back (value_type &&__x)
 
void push_front (const value_type &__x)
 
void push_front (value_type &&__x)
 
const_reverse_iterator rbegin () const noexcept
 
reverse_iterator rbegin () noexcept
 
__remove_return_type remove (const _Tp &__value)
 
template<typename _Predicate >
__remove_return_type remove_if (_Predicate)
 
const_reverse_iterator rend () const noexcept
 
reverse_iterator rend () noexcept
 
void resize (size_type __new_size)
 
void resize (size_type __new_size, const value_type &__x)
 
void reverse () noexcept
 
size_type size () const noexcept
 
void sort ()
 
template<typename _StrictWeakOrdering >
void sort (_StrictWeakOrdering)
 
void splice (const_iterator __position, list &&__x) noexcept
 
void splice (const_iterator __position, list &&__x, const_iterator __first, const_iterator __last) noexcept
 
void splice (const_iterator __position, list &&__x, const_iterator __i) noexcept
 
void splice (const_iterator __position, list &__x) noexcept
 
void splice (const_iterator __position, list &__x, const_iterator __first, const_iterator __last) noexcept
 
void splice (const_iterator __position, list &__x, const_iterator __i) noexcept
 
void swap (list &__x) noexcept
 
__remove_return_type unique ()
 
template<typename _BinaryPredicate >
__remove_return_type unique (_BinaryPredicate)
 

Protected Types

typedef _List_node< _Tp > _Node
 

Protected Member Functions

template<typename _InputIterator >
void _M_assign_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
 
template<typename _Integer >
void _M_assign_dispatch (_Integer __n, _Integer __val, __true_type)
 
void _M_check_equal_allocators (list &__x) noexcept
 
void _M_clear () noexcept
 
template<typename... _Args>
_Node_M_create_node (_Args &&... __args)
 
void _M_dec_size (size_t)
 
void _M_default_append (size_type __n)
 
void _M_default_initialize (size_type __n)
 
size_t _M_distance (const void *, const void *) const
 
void _M_erase (iterator __position) noexcept
 
void _M_fill_assign (size_type __n, const value_type &__val)
 
void _M_fill_initialize (size_type __n, const value_type &__x)
 
_Node_alloc_traits::pointer _M_get_node ()
 
const _Node_alloc_type & _M_get_Node_allocator () const noexcept
 
_Node_alloc_type & _M_get_Node_allocator () noexcept
 
size_t _M_get_size () const
 
void _M_inc_size (size_t)
 
void _M_init () noexcept
 
template<typename _InputIterator >
void _M_initialize_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
 
template<typename _Integer >
void _M_initialize_dispatch (_Integer __n, _Integer __x, __true_type)
 
template<typename... _Args>
void _M_insert (iterator __position, _Args &&... __args)
 
void _M_move_assign (list &&__x, false_type)
 
void _M_move_assign (list &&__x, true_type) noexcept
 
void _M_move_nodes (_List_base &&__x)
 
size_t _M_node_count () const
 
void _M_put_node (typename _Node_alloc_traits::pointer __p) noexcept
 
const_iterator _M_resize_pos (size_type &__new_size) const
 
void _M_set_size (size_t)
 
void _M_transfer (iterator __position, iterator __first, iterator __last)
 

Static Protected Member Functions

static size_t _S_distance (const __detail::_List_node_base *__first, const __detail::_List_node_base *__last)
 
static size_t _S_distance (const_iterator, const_iterator)
 

Protected Attributes

_List_impl _M_impl
 

Detailed Description

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
class std::list< _Tp, _Alloc >

A standard container with linear time access to elements, and fixed time insertion/deletion at any point in the sequence.

Template Parameters
_TpType of element.
_AllocAllocator type, defaults to allocator<_Tp>.

Meets the requirements of a container, a reversible container, and a sequence, including the optional sequence requirements with the exception of at and operator[].

This is a doubly linked list. Traversal up and down the list requires linear time, but adding and removing elements (or nodes) is done in constant time, regardless of where the change takes place. Unlike std::vector and std::deque, random-access iterators are not provided, so subscripting ( [] ) access is not allowed. For algorithms which only need sequential access, this lack makes no difference.

Also unlike the other standard containers, std::list provides specialized algorithms unique to linked lists, such as splicing, sorting, and in-place reversal.

A couple points on memory allocation for list<Tp>:

First, we never actually allocate a Tp, we allocate List_node<Tp>'s and trust [20.1.5]/4 to DTRT. This is to ensure that after elements from list<X,Alloc1> are spliced into list<X,Alloc2>, destroying the memory of the second list is a valid operation, i.e., Alloc1 giveth and Alloc2 taketh away.

Second, a list conceptually represented as

A <---> B <---> C <---> D

is actually circular; a link exists between A and D. The list class holds (as its only data member) a private list::iterator pointing to D, not to A! To get to the head of the list, we start at the tail and move forward by one. When this member iterator's next/previous pointers refer to itself, the list is empty.

Definition at line 557 of file stl_list.h.

Member Typedef Documentation

◆ _Node

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _List_node<_Tp> std::list< _Tp, _Alloc >::_Node
protected

Definition at line 600 of file stl_list.h.

◆ allocator_type

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _Alloc std::list< _Tp, _Alloc >::allocator_type

Definition at line 595 of file stl_list.h.

◆ const_iterator

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _List_const_iterator<_Tp> std::list< _Tp, _Alloc >::const_iterator

Definition at line 590 of file stl_list.h.

◆ const_pointer

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_traits::const_pointer std::list< _Tp, _Alloc >::const_pointer

Definition at line 586 of file stl_list.h.

◆ const_reference

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_traits::const_reference std::list< _Tp, _Alloc >::const_reference

Definition at line 588 of file stl_list.h.

◆ const_reverse_iterator

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef std::reverse_iterator<const_iterator> std::list< _Tp, _Alloc >::const_reverse_iterator

Definition at line 591 of file stl_list.h.

◆ difference_type

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef ptrdiff_t std::list< _Tp, _Alloc >::difference_type

Definition at line 594 of file stl_list.h.

◆ iterator

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _List_iterator<_Tp> std::list< _Tp, _Alloc >::iterator

Definition at line 589 of file stl_list.h.

◆ pointer

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_traits::pointer std::list< _Tp, _Alloc >::pointer

Definition at line 585 of file stl_list.h.

◆ reference

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_traits::reference std::list< _Tp, _Alloc >::reference

Definition at line 587 of file stl_list.h.

◆ reverse_iterator

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef std::reverse_iterator<iterator> std::list< _Tp, _Alloc >::reverse_iterator

Definition at line 592 of file stl_list.h.

◆ size_type

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef size_t std::list< _Tp, _Alloc >::size_type

Definition at line 593 of file stl_list.h.

◆ value_type

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
typedef _Tp std::list< _Tp, _Alloc >::value_type

Definition at line 584 of file stl_list.h.

Constructor & Destructor Documentation

◆ list() [1/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( )
default

Creates a list with no elements.

◆ list() [2/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( const allocator_type &  __a)
inlineexplicitnoexcept

Creates a list with no elements.

Parameters
__aAn allocator object.

Definition at line 684 of file stl_list.h.

◆ list() [3/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( size_type  __n,
const allocator_type &  __a = allocator_type() 
)
inlineexplicit

Creates a list with default constructed elements.

Parameters
__nThe number of elements to initially create.
__aAn allocator object.

This constructor fills the list with __n default constructed elements.

Definition at line 697 of file stl_list.h.

◆ list() [4/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( size_type  __n,
const value_type &  __value,
const allocator_type &  __a = allocator_type() 
)
inline

Creates a list with copies of an exemplar element.

Parameters
__nThe number of elements to initially create.
__valueAn element to copy.
__aAn allocator object.

This constructor fills the list with __n copies of __value.

Definition at line 709 of file stl_list.h.

◆ list() [5/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( const list< _Tp, _Alloc > &  __x)
inline

List copy constructor.

Parameters
__xA list of identical element and allocator types.

The newly-created list uses a copy of the allocation object used by __x (unless the allocator traits dictate a different object).

Definition at line 736 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

◆ list() [6/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( list< _Tp, _Alloc > &&  )
default

List move constructor.

The newly-created list contains the exact contents of the moved instance. The contents of the moved instance are a valid, but unspecified list.

◆ list() [7/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( initializer_list< value_type >  __l,
const allocator_type &  __a = allocator_type() 
)
inline

Builds a list from an initializer_list.

Parameters
__lAn initializer_list of value_type.
__aAn allocator object.

Create a list consisting of copies of the elements in the initializer_list __l. This is linear in __l.size().

Definition at line 759 of file stl_list.h.

◆ list() [8/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( const list< _Tp, _Alloc > &  __x,
const allocator_type &  __a 
)
inline

Definition at line 764 of file stl_list.h.

◆ list() [9/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::list ( list< _Tp, _Alloc > &&  __x,
const allocator_type &  __a 
)
inlinenoexcept

Definition at line 784 of file stl_list.h.

◆ list() [10/10]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>>
std::list< _Tp, _Alloc >::list ( _InputIterator  __first,
_InputIterator  __last,
const allocator_type &  __a = allocator_type() 
)
inline

Builds a list from a range.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__aAn allocator object.

Create a list consisting of copies of the elements from [__first,__last). This is linear in N (where N is distance(__first,__last)).

Definition at line 804 of file stl_list.h.

◆ ~list()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
std::list< _Tp, _Alloc >::~list ( )
default

No explicit dtor needed as the _Base dtor takes care of things. The _Base dtor only erases the elements, and note that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Member Function Documentation

◆ _M_assign_dispatch() [1/2]

template<typename _Tp , typename _Alloc >
template<typename _InputIterator >
void list::_M_assign_dispatch ( _InputIterator  __first,
_InputIterator  __last,
__false_type   
)
protected

Definition at line 308 of file list.tcc.

◆ _M_assign_dispatch() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _Integer >
void std::list< _Tp, _Alloc >::_M_assign_dispatch ( _Integer  __n,
_Integer  __val,
__true_type   
)
inlineprotected

Definition at line 1878 of file stl_list.h.

◆ _M_check_equal_allocators()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_check_equal_allocators ( list< _Tp, _Alloc > &  __x)
inlineprotectednoexcept

Definition at line 1936 of file stl_list.h.

◆ _M_clear()

template<typename _Tp , typename _Alloc >
void std::_List_base< _Tp, _Alloc >::_M_clear
noexceptinherited

Definition at line 66 of file list.tcc.

◆ _M_create_node()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename... _Args>
_Node * std::list< _Tp, _Alloc >::_M_create_node ( _Args &&...  __args)
inlineprotected
Parameters
__argsAn instance of user data.

Allocates space for a new node and constructs a copy of __args in it.

Definition at line 633 of file stl_list.h.

◆ _M_dec_size()

template<typename _Tp , typename _Alloc >
void std::_List_base< _Tp, _Alloc >::_M_dec_size ( size_t  )
inlineprotectedinherited

Definition at line 427 of file stl_list.h.

◆ _M_default_append()

template<typename _Tp , typename _Alloc >
void list::_M_default_append ( size_type  __n)
protected

Definition at line 211 of file list.tcc.

◆ _M_default_initialize()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_default_initialize ( size_type  __n)
inlineprotected

Definition at line 1859 of file stl_list.h.

◆ _M_distance()

template<typename _Tp , typename _Alloc >
size_t std::_List_base< _Tp, _Alloc >::_M_distance ( const void *  ,
const void *   
) const
inlineprotectedinherited

Definition at line 430 of file stl_list.h.

◆ _M_erase()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_erase ( iterator  __position)
inlineprotectednoexcept

Definition at line 1920 of file stl_list.h.

◆ _M_fill_assign()

template<typename _Tp , typename _Alloc >
void list::_M_fill_assign ( size_type  __n,
const value_type &  __val 
)
protected

Definition at line 293 of file list.tcc.

◆ _M_fill_initialize()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_fill_initialize ( size_type  __n,
const value_type &  __x 
)
inlineprotected

Definition at line 1850 of file stl_list.h.

◆ _M_get_node()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
_Node_alloc_traits::pointer std::_List_base< _Tp, _Alloc >::_M_get_node ( )
inlineprotected

Definition at line 442 of file stl_list.h.

◆ _M_get_Node_allocator() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const _Node_alloc_type & std::_List_base< _Tp, _Alloc >::_M_get_Node_allocator ( ) const
inlineprotectednoexcept

Definition at line 457 of file stl_list.h.

◆ _M_get_Node_allocator() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
_Node_alloc_type & std::_List_base< _Tp, _Alloc >::_M_get_Node_allocator ( )
inlineprotectednoexcept

Definition at line 453 of file stl_list.h.

◆ _M_get_size()

template<typename _Tp , typename _Alloc >
size_t std::_List_base< _Tp, _Alloc >::_M_get_size ( ) const
inlineprotectedinherited

Definition at line 424 of file stl_list.h.

◆ _M_inc_size()

template<typename _Tp , typename _Alloc >
void std::_List_base< _Tp, _Alloc >::_M_inc_size ( size_t  )
inlineprotectedinherited

Definition at line 426 of file stl_list.h.

◆ _M_init()

template<typename _Tp , typename _Alloc >
void std::_List_base< _Tp, _Alloc >::_M_init ( )
inlinenoexceptinherited

Definition at line 506 of file stl_list.h.

◆ _M_initialize_dispatch() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator >
void std::list< _Tp, _Alloc >::_M_initialize_dispatch ( _InputIterator  __first,
_InputIterator  __last,
__false_type   
)
inlineprotected

Definition at line 1836 of file stl_list.h.

◆ _M_initialize_dispatch() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _Integer >
void std::list< _Tp, _Alloc >::_M_initialize_dispatch ( _Integer  __n,
_Integer  __x,
__true_type   
)
inlineprotected

Definition at line 1830 of file stl_list.h.

◆ _M_insert()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename... _Args>
void std::list< _Tp, _Alloc >::_M_insert ( iterator  __position,
_Args &&...  __args 
)
inlineprotected

Definition at line 1910 of file stl_list.h.

◆ _M_move_assign() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_move_assign ( list< _Tp, _Alloc > &&  __x,
false_type   
)
inlineprotected

Definition at line 1958 of file stl_list.h.

◆ _M_move_assign() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_move_assign ( list< _Tp, _Alloc > &&  __x,
true_type   
)
inlineprotectednoexcept

Definition at line 1949 of file stl_list.h.

◆ _M_move_nodes()

template<typename _Tp , typename _Alloc >
void std::_List_base< _Tp, _Alloc >::_M_move_nodes ( _List_base< _Tp, _Alloc > &&  __x)
inlineinherited

Definition at line 494 of file stl_list.h.

◆ _M_node_count()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
size_t std::list< _Tp, _Alloc >::_M_node_count ( ) const
inlineprotected

Definition at line 662 of file stl_list.h.

◆ _M_put_node()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::_List_base< _Tp, _Alloc >::_M_put_node ( typename _Node_alloc_traits::pointer  __p)
inlineprotectednoexcept

Definition at line 446 of file stl_list.h.

◆ _M_resize_pos()

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc >::const_iterator list::_M_resize_pos ( size_type &  __new_size) const
protected

Definition at line 175 of file list.tcc.

◆ _M_set_size()

template<typename _Tp , typename _Alloc >
void std::_List_base< _Tp, _Alloc >::_M_set_size ( size_t  )
inlineprotectedinherited

Definition at line 425 of file stl_list.h.

◆ _M_transfer()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::_M_transfer ( iterator  __position,
iterator  __first,
iterator  __last 
)
inlineprotected

Definition at line 1895 of file stl_list.h.

◆ _S_distance() [1/2]

template<typename _Tp , typename _Alloc >
static size_t std::_List_base< _Tp, _Alloc >::_S_distance ( const __detail::_List_node_base __first,
const __detail::_List_node_base __last 
)
inlinestaticprotectedinherited

Definition at line 362 of file stl_list.h.

◆ _S_distance() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
static size_t std::list< _Tp, _Alloc >::_S_distance ( const_iterator  ,
const_iterator   
)
inlinestaticprotected

Definition at line 657 of file stl_list.h.

◆ assign() [1/3]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>>
void std::list< _Tp, _Alloc >::assign ( _InputIterator  __first,
_InputIterator  __last 
)
inline

Assigns a range to a list.

Parameters
__firstAn input iterator.
__lastAn input iterator.

This function fills a list with copies of the elements in the range [__first,__last).

Note that the assignment completely changes the list and that the resulting list's size is the same as the number of elements assigned.

Definition at line 909 of file stl_list.h.

◆ assign() [2/3]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::assign ( initializer_list< value_type >  __l)
inline

Assigns an initializer_list to a list.

Parameters
__lAn initializer_list of value_type.

Replace the contents of the list with copies of the elements in the initializer_list __l. This is linear in __l.size().

Definition at line 931 of file stl_list.h.

◆ assign() [3/3]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::assign ( size_type  __n,
const value_type &  __val 
)
inline

Assigns a given value to a list.

Parameters
__nNumber of elements to be assigned.
__valValue to be assigned.

This function fills a list with __n copies of the given value. Note that the assignment completely changes the list and that the resulting list's size is the same as the number of elements assigned.

Definition at line 890 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::operator=().

◆ back() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reference std::list< _Tp, _Alloc >::back ( ) const
inlinenoexcept

Returns a read-only (constant) reference to the data at the last element of the list.

Definition at line 1143 of file stl_list.h.

References std::list< _Tp, _Alloc >::end().

◆ back() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
reference std::list< _Tp, _Alloc >::back ( )
inlinenoexcept

Returns a read/write reference to the data at the last element of the list.

Definition at line 1131 of file stl_list.h.

References std::list< _Tp, _Alloc >::end().

◆ begin() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::list< _Tp, _Alloc >::begin ( ) const
inlinenoexcept

Returns a read-only (constant) iterator that points to the first element in the list. Iteration is done in ordinary element order.

Definition at line 955 of file stl_list.h.

◆ begin() [2/2]

◆ cbegin()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::list< _Tp, _Alloc >::cbegin ( ) const
inlinenoexcept

Returns a read-only (constant) iterator that points to the first element in the list. Iteration is done in ordinary element order.

Definition at line 1019 of file stl_list.h.

◆ cend()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::list< _Tp, _Alloc >::cend ( ) const
inlinenoexcept

Returns a read-only (constant) iterator that points one past the last element in the list. Iteration is done in ordinary element order.

Definition at line 1028 of file stl_list.h.

◆ clear()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::clear ( )
inlinenoexcept

Erases all the elements. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 1499 of file stl_list.h.

◆ crbegin()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::list< _Tp, _Alloc >::crbegin ( ) const
inlinenoexcept

Returns a read-only (constant) reverse iterator that points to the last element in the list. Iteration is done in reverse element order.

Definition at line 1037 of file stl_list.h.

References std::list< _Tp, _Alloc >::end().

◆ crend()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::list< _Tp, _Alloc >::crend ( ) const
inlinenoexcept

Returns a read-only (constant) reverse iterator that points to one before the first element in the list. Iteration is done in reverse element order.

Definition at line 1046 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ emplace()

template<typename _Tp , typename _Alloc >
template<typename... _Args>
list< _Tp, _Alloc >::iterator list::emplace ( const_iterator  __position,
_Args &&...  __args 
)

Constructs object in list before specified iterator.

Parameters
__positionA const_iterator into the list.
__argsArguments.
Returns
An iterator that points to the inserted data.

This function will insert an object of type T constructed with T(std::forward<Args>(args)...) before the specified location. Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 89 of file list.tcc.

Referenced by std::list< _Tp, _Alloc >::insert().

◆ emplace_back()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename... _Args>
reference std::list< _Tp, _Alloc >::emplace_back ( _Args &&...  __args)
inline

Definition at line 1226 of file stl_list.h.

◆ emplace_front()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename... _Args>
reference std::list< _Tp, _Alloc >::emplace_front ( _Args &&...  __args)
inline

Definition at line 1176 of file stl_list.h.

◆ empty()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
bool std::list< _Tp, _Alloc >::empty ( ) const
inlinenoexcept

Returns true if the list is empty. (Thus begin() would equal end().)

Definition at line 1056 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::insert(), std::list< _Tp, _Alloc >::sort(), std::list< _Tp, _Alloc >::sort(), and std::list< _Tp, _Alloc >::splice().

◆ end() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::list< _Tp, _Alloc >::end ( ) const
inlinenoexcept

Returns a read-only (constant) iterator that points one past the last element in the list. Iteration is done in ordinary element order.

Definition at line 973 of file stl_list.h.

◆ end() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
iterator std::list< _Tp, _Alloc >::end ( )
inlinenoexcept

◆ erase() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
iterator std::list< _Tp, _Alloc >::erase ( const_iterator  __first,
const_iterator  __last 
)
inlinenoexcept

Remove a range of elements.

Parameters
__firstIterator pointing to the first element to be erased.
__lastIterator pointing to one past the last element to be erased.
Returns
An iterator pointing to the element pointed to by last prior to erasing (or end()).

This function will erase the elements in the range [first,last) and shorten the list accordingly.

This operation is linear time in the size of the range and only invalidates iterators/references to the element being removed. The user is also cautioned that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 1457 of file stl_list.h.

References std::list< _Tp, _Alloc >::erase().

◆ erase() [2/2]

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc >::iterator list::erase ( const_iterator  __position)
noexcept

Remove element at given position.

Parameters
__positionIterator pointing to element to be erased.
Returns
An iterator pointing to the next element (or end()).

This function will erase the element at the given position and thus shorten the list by one.

Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed. The user is also cautioned that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 150 of file list.tcc.

Referenced by std::list< _Tp, _Alloc >::erase().

◆ front() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reference std::list< _Tp, _Alloc >::front ( ) const
inlinenoexcept

Returns a read-only (constant) reference to the data at the first element of the list.

Definition at line 1123 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ front() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
reference std::list< _Tp, _Alloc >::front ( )
inlinenoexcept

Returns a read/write reference to the data at the first element of the list.

Definition at line 1115 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ get_allocator()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
allocator_type std::list< _Tp, _Alloc >::get_allocator ( ) const
inlinenoexcept

Get a copy of the memory allocation object.

Definition at line 937 of file stl_list.h.

◆ insert() [1/5]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
iterator std::list< _Tp, _Alloc >::insert ( const_iterator  __p,
initializer_list< value_type >  __l 
)
inline

Inserts the contents of an initializer_list into list before specified const_iterator.

Parameters
__pA const_iterator into the list.
__lAn initializer_list of value_type.
Returns
An iterator pointing to the first element inserted (or __position).

This function will insert copies of the data in the initializer_list l into the list before the location specified by p.

This operation is linear in the number of elements inserted and does not invalidate iterators and references.

Definition at line 1328 of file stl_list.h.

References std::list< _Tp, _Alloc >::insert().

◆ insert() [2/5]

template<typename _Tp , typename _Alloc >
template<typename _InputIterator , typename >
list< _Tp, _Alloc >::iterator list::insert ( const_iterator  __position,
_InputIterator  __first,
_InputIterator  __last 
)

Inserts a range into the list.

Parameters
__positionA const_iterator into the list.
__firstAn input iterator.
__lastAn input iterator.
Returns
An iterator pointing to the first element inserted (or __position).

This function will insert copies of the data in the range [first,last) into the list before the location specified by position.

This operation is linear in the number of elements inserted and does not invalidate iterators and references.

Definition at line 133 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::empty().

◆ insert() [3/5]

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc >::iterator list::insert ( const_iterator  __position,
const value_type &  __x 
)

Inserts given value into list before specified iterator.

Parameters
__positionA const_iterator into the list.
__xData to be inserted.
Returns
An iterator that points to the inserted data.

This function will insert a copy of the given value before the specified location. Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 101 of file list.tcc.

Referenced by std::list< _Tp, _Alloc >::insert().

◆ insert() [4/5]

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc >::iterator list::insert ( const_iterator  __position,
size_type  __n,
const value_type &  __x 
)

Inserts a number of copies of given data into the list.

Parameters
__positionA const_iterator into the list.
__nNumber of elements to be inserted.
__xData to be inserted.
Returns
An iterator pointing to the first element inserted (or __position).

This function will insert a specified number of copies of the given data before the location specified by position.

This operation is linear in the number of elements inserted and does not invalidate iterators and references.

Definition at line 117 of file list.tcc.

References std::list< _Tp, _Alloc >::begin().

◆ insert() [5/5]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
iterator std::list< _Tp, _Alloc >::insert ( const_iterator  __position,
value_type &&  __x 
)
inline

Inserts given rvalue into list before specified iterator.

Parameters
__positionA const_iterator into the list.
__xData to be inserted.
Returns
An iterator that points to the inserted data.

This function will insert a copy of the given rvalue before the specified location. Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 1309 of file stl_list.h.

References std::list< _Tp, _Alloc >::emplace(), and std::move().

◆ max_size()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
size_type std::list< _Tp, _Alloc >::max_size ( ) const
inlinenoexcept

Returns the size() of the largest possible list.

Definition at line 1066 of file stl_list.h.

References __gnu_cxx::__alloc_traits< _Alloc, typename >::max_size().

◆ merge() [1/4]

template<typename _Tp , typename _Alloc >
void list::merge ( list< _Tp, _Alloc > &&  __x)

Merge sorted lists.

Parameters
__xSorted list to merge.

Assumes that both __x and this list are sorted according to operator<(). Merges elements of __x into this list in sorted order, leaving __x empty when complete. Elements in this list precede elements in __x that are equal.

Definition at line 402 of file list.tcc.

References std::__addressof(), std::list< _Tp, _Alloc >::begin(), std::begin(), std::list< _Tp, _Alloc >::end(), and std::end().

Referenced by std::list< _Tp, _Alloc >::sort(), and std::list< _Tp, _Alloc >::sort().

◆ merge() [2/4]

template<typename _Tp , typename _Alloc >
template<typename _StrictWeakOrdering >
void list::merge ( list< _Tp, _Alloc > &&  __x,
_StrictWeakOrdering  __comp 
)

Merge sorted lists according to comparison function.

Template Parameters
_StrictWeakOrderingComparison function defining sort order.
Parameters
__xSorted list to merge.
__compComparison functor.

Assumes that both __x and this list are sorted according to StrictWeakOrdering. Merges elements of __x into this list in sorted order, leaving __x empty when complete. Elements in this list precede elements in __x that are equivalent according to StrictWeakOrdering().

Definition at line 442 of file list.tcc.

References std::__addressof(), std::list< _Tp, _Alloc >::begin(), std::begin(), std::list< _Tp, _Alloc >::end(), and std::end().

◆ merge() [3/4]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::merge ( list< _Tp, _Alloc > &  __x)
inline

Definition at line 1758 of file stl_list.h.

◆ merge() [4/4]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _StrictWeakOrdering >
void std::list< _Tp, _Alloc >::merge ( list< _Tp, _Alloc > &  __x,
_StrictWeakOrdering  __comp 
)
inline

Definition at line 1785 of file stl_list.h.

◆ operator=() [1/3]

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc > & list::operator= ( const list< _Tp, _Alloc > &  __x)

List assignment operator.

Parameters
__xA list of identical element and allocator types.

All the elements of __x are copied.

Whether the allocator is copied depends on the allocator traits.

Definition at line 267 of file list.tcc.

References std::__addressof(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

◆ operator=() [2/3]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
list & std::list< _Tp, _Alloc >::operator= ( initializer_list< value_type >  __l)
inline

List initializer list assignment operator.

Parameters
__lAn initializer_list of value_type.

Replace the contents of the list with copies of the elements in the initializer_list __l. This is linear in l.size().

Definition at line 872 of file stl_list.h.

References std::list< _Tp, _Alloc >::assign().

◆ operator=() [3/3]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
list & std::list< _Tp, _Alloc >::operator= ( list< _Tp, _Alloc > &&  __x)
inlinenoexcept

List move assignment operator.

Parameters
__xA list of identical element and allocator types.

The contents of __x are moved into this list (without copying).

Afterwards __x is a valid, but unspecified list

Whether the allocator is moved depends on the allocator traits.

Definition at line 854 of file stl_list.h.

References std::move().

◆ pop_back()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::pop_back ( )
inlinenoexcept

Removes last element.

This is a typical stack operation. It shrinks the list by one. Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed.

Note that no data is returned, and if the last element's data is needed, it should be retrieved before pop_back() is called.

Definition at line 1247 of file stl_list.h.

◆ pop_front()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::pop_front ( )
inlinenoexcept

Removes first element.

This is a typical stack operation. It shrinks the list by one. Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed.

Note that no data is returned, and if the first element's data is needed, it should be retrieved before pop_front() is called.

Definition at line 1198 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ push_back() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::push_back ( const value_type &  __x)
inline

Add data to the end of the list.

Parameters
__xData to be added.

This is a typical stack operation. The function creates an element at the end of the list and assigns the given data to it. Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 1212 of file stl_list.h.

References std::list< _Tp, _Alloc >::end().

◆ push_back() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::push_back ( value_type &&  __x)
inline

Definition at line 1217 of file stl_list.h.

◆ push_front() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::push_front ( const value_type &  __x)
inline

Add data to the front of the list.

Parameters
__xData to be added.

This is a typical stack operation. The function creates an element at the front of the list and assigns the given data to it. Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 1162 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ push_front() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::push_front ( value_type &&  __x)
inline

Definition at line 1167 of file stl_list.h.

◆ rbegin() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::list< _Tp, _Alloc >::rbegin ( ) const
inlinenoexcept

Returns a read-only (constant) reverse iterator that points to the last element in the list. Iteration is done in reverse element order.

Definition at line 991 of file stl_list.h.

References std::list< _Tp, _Alloc >::end().

◆ rbegin() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
reverse_iterator std::list< _Tp, _Alloc >::rbegin ( )
inlinenoexcept

Returns a read/write reverse iterator that points to the last element in the list. Iteration is done in reverse element order.

Definition at line 982 of file stl_list.h.

References std::list< _Tp, _Alloc >::end().

◆ remove()

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc >::__remove_return_type list::remove ( const _Tp &  __value)

Remove all elements equal to value.

Parameters
__valueThe value to remove.

Removes every element in the list equal to value. Remaining elements stay in list order. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 331 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::begin(), std::end(), std::list< _Tp, _Alloc >::size(), and std::list< _Tp, _Alloc >::splice().

◆ remove_if()

template<typename _Tp , typename _Alloc >
template<typename _Predicate >
list< _Tp, _Alloc >::__remove_return_type list::remove_if ( _Predicate  __pred)

Remove all elements satisfying a predicate.

Template Parameters
_PredicateUnary predicate function or object.

Removes every element in the list for which the predicate returns true. Remaining elements stay in list order. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 528 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::begin(), std::end(), std::list< _Tp, _Alloc >::size(), and std::list< _Tp, _Alloc >::splice().

◆ rend() [1/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::list< _Tp, _Alloc >::rend ( ) const
inlinenoexcept

Returns a read-only (constant) reverse iterator that points to one before the first element in the list. Iteration is done in reverse element order.

Definition at line 1009 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ rend() [2/2]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
reverse_iterator std::list< _Tp, _Alloc >::rend ( )
inlinenoexcept

Returns a read/write reverse iterator that points to one before the first element in the list. Iteration is done in reverse element order.

Definition at line 1000 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin().

◆ resize() [1/2]

template<typename _Tp , typename _Alloc >
void list::resize ( size_type  __new_size)

Resizes the list to the specified number of elements.

Parameters
__new_sizeNumber of elements the list should contain.

This function will resize the list to the specified number of elements. If the number is smaller than the list's current size the list is truncated, otherwise default constructed elements are appended.

Definition at line 230 of file list.tcc.

References std::end().

◆ resize() [2/2]

template<typename _Tp , typename _Alloc >
void list::resize ( size_type  __new_size,
const value_type &  __x 
)

Resizes the list to the specified number of elements.

Parameters
__new_sizeNumber of elements the list should contain.
__xData with which new elements should be populated.

This function will resize the list to the specified number of elements. If the number is smaller than the list's current size the list is truncated, otherwise the list is extended and new elements are populated with given data.

Definition at line 242 of file list.tcc.

References std::end().

◆ reverse()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::reverse ( )
inlinenoexcept

Reverse the elements in list.

Reverse the order of elements in the list in linear time.

Definition at line 1799 of file stl_list.h.

◆ size()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
size_type std::list< _Tp, _Alloc >::size ( ) const
inlinenoexcept

◆ sort() [1/2]

template<typename _Tp , typename _Alloc >
void list::sort

Sort the elements.

Sorts the elements of this list in NlogN time. Equivalent elements remain in list order.

Definition at line 481 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::begin(), std::list< _Tp, _Alloc >::empty(), std::empty(), std::end(), std::list< _Tp, _Alloc >::merge(), std::list< _Tp, _Alloc >::splice(), std::swap(), and std::list< _Tp, _Alloc >::swap().

◆ sort() [2/2]

template<typename _Tp , typename _Alloc >
template<typename _StrictWeakOrdering >
void list::sort ( _StrictWeakOrdering  __comp)

Sort the elements according to comparison function.

Sorts the elements of this list in NlogN time. Equivalent elements remain in list order.

Definition at line 599 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::begin(), std::list< _Tp, _Alloc >::empty(), std::empty(), std::end(), std::list< _Tp, _Alloc >::merge(), std::list< _Tp, _Alloc >::splice(), std::swap(), and std::list< _Tp, _Alloc >::swap().

◆ splice() [1/6]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::splice ( const_iterator  __position,
list< _Tp, _Alloc > &&  __x 
)
inlinenoexcept

Insert contents of another list.

Parameters
__positionIterator referencing the element to insert before.
__xSource list.

The elements of __x are inserted in constant time in front of the element referenced by __position. __x becomes an empty list.

Requires this != __x.

Definition at line 1519 of file stl_list.h.

References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::empty(), and std::list< _Tp, _Alloc >::end().

Referenced by std::list< _Tp, _Alloc >::remove(), std::list< _Tp, _Alloc >::remove_if(), std::list< _Tp, _Alloc >::sort(), std::list< _Tp, _Alloc >::sort(), std::list< _Tp, _Alloc >::splice(), std::list< _Tp, _Alloc >::splice(), std::list< _Tp, _Alloc >::unique(), and std::list< _Tp, _Alloc >::unique().

◆ splice() [2/6]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::splice ( const_iterator  __position,
list< _Tp, _Alloc > &&  __x,
const_iterator  __first,
const_iterator  __last 
)
inlinenoexcept

Insert range from another list.

Parameters
__positionConst_iterator referencing the element to insert before.
__xSource list.
__firstConst_iterator referencing the start of range in x.
__lastConst_iterator referencing the end of range in x.

Removes elements in the range [__first,__last) and inserts them before __position in constant time.

Undefined if __position is in [__first,__last).

Definition at line 1615 of file stl_list.h.

References std::__addressof().

◆ splice() [3/6]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::splice ( const_iterator  __position,
list< _Tp, _Alloc > &&  __x,
const_iterator  __i 
)
inlinenoexcept

Insert element from another list.

Parameters
__positionConst_iterator referencing the element to insert before.
__xSource list.
__iConst_iterator referencing the element to move.

Removes the element in list __x referenced by __i and inserts it into the current list before __position.

Definition at line 1554 of file stl_list.h.

References std::__addressof().

◆ splice() [4/6]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::splice ( const_iterator  __position,
list< _Tp, _Alloc > &  __x 
)
inlinenoexcept

Definition at line 1538 of file stl_list.h.

◆ splice() [5/6]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::splice ( const_iterator  __position,
list< _Tp, _Alloc > &  __x,
const_iterator  __first,
const_iterator  __last 
)
inlinenoexcept

Insert range from another list.

Parameters
__positionConst_iterator referencing the element to insert before.
__xSource list.
__firstConst_iterator referencing the start of range in x.
__lastConst_iterator referencing the end of range in x.

Removes elements in the range [__first,__last) and inserts them before __position in constant time.

Undefined if __position is in [__first,__last).

Definition at line 1665 of file stl_list.h.

References std::move(), and std::list< _Tp, _Alloc >::splice().

◆ splice() [6/6]

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::splice ( const_iterator  __position,
list< _Tp, _Alloc > &  __x,
const_iterator  __i 
)
inlinenoexcept

Insert element from another list.

Parameters
__positionConst_iterator referencing the element to insert before.
__xSource list.
__iConst_iterator referencing the element to move.

Removes the element in list __x referenced by __i and inserts it into the current list before __position.

Definition at line 1596 of file stl_list.h.

References std::move(), and std::list< _Tp, _Alloc >::splice().

◆ swap()

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
void std::list< _Tp, _Alloc >::swap ( list< _Tp, _Alloc > &  __x)
inlinenoexcept

Swaps data with another list.

Parameters
__xA list of the same element and allocator types.

This exchanges the elements between two lists in constant time. Note that the global std::swap() function is specialized such that std::swap(l1,l2) will feed to this function.

Whether the allocators are swapped depends on the allocator traits.

Definition at line 1479 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::sort(), and std::list< _Tp, _Alloc >::sort().

◆ unique() [1/2]

template<typename _Tp , typename _Alloc >
list< _Tp, _Alloc >::__remove_return_type list::unique

Remove consecutive duplicate elements.

For each consecutive set of elements with the same value, remove all but the first one. Remaining elements stay in list order. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 367 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::begin(), std::end(), std::list< _Tp, _Alloc >::size(), and std::list< _Tp, _Alloc >::splice().

◆ unique() [2/2]

template<typename _Tp , typename _Alloc >
template<typename _BinaryPredicate >
list< _Tp, _Alloc >::__remove_return_type list::unique ( _BinaryPredicate  __binary_pred)

Remove consecutive elements satisfying a predicate.

Template Parameters
_BinaryPredicateBinary predicate function or object.

For each consecutive set of elements [first,last) that satisfy predicate(first,i) where i is an iterator in [first,last), remove all but the first one. Remaining elements stay in list order. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Definition at line 561 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::begin(), std::end(), std::list< _Tp, _Alloc >::size(), and std::list< _Tp, _Alloc >::splice().

Member Data Documentation

◆ _M_impl

template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
_List_impl std::_List_base< _Tp, _Alloc >::_M_impl
protected

Definition at line 402 of file stl_list.h.


The documentation for this class was generated from the following files: