std::list::list

(1) explicit list( const Allocator& alloc = Allocator() ); (until C++14) list() : list( Allocator() ) {} explicit list( const Allocator& alloc ); (since C++14) (2) explicit list( size_type count, const T& value = T(), const Allocator& alloc = Allocator()); (until C++11) list( size_type count, const T& value, const Allocator& alloc = Allocator()); (since C++11) (3) explicit l

std::list::insert

(1) iterator insert( iterator pos, const T& value ); (until C++11) iterator insert( const_iterator pos, const T& value ); (since C++11) iterator insert( const_iterator pos, T&& value ); (2) (since C++11) (3) void insert( iterator pos, size_type count, const T& value ); (until C++11) iterator insert( const_iterator pos, size_type count, const T& value ); (since C++11) (4) template< class InputIt > void insert( iterator pos, InputIt f

std::list::get_allocator

allocator_type get_allocator() const; Returns the allocator associated with the container. Parameters (none). Return value The associated allocator. Complexity Constant.

std::list::front

reference front(); const_reference front() const; Returns a reference to the first element in the container. Calling front on an empty container is undefined. Parameters (none). Return value reference to the first element. Complexity Constant. Notes For a container c, the expression c.front() is equivalent to *c.begin(). Example The following code uses front to display the first element of a std::list<char>: #include <list> #include <iostream> i

std::list::erase

(1) iterator erase( iterator pos ); (until C++11) iterator erase( const_iterator pos ); (since C++11) (2) iterator erase( iterator first, iterator last ); (until C++11) iterator erase( const_iterator first, const_iterator last ); (since C++11) Removes specified elements from the container. 1) Removes the element at pos. 2) Removes the elements in the range [first; last). References and iterators to the erased elements are invalidated. Other references and iterators a

std::list::end

iterator end(); const_iterator end() const; const_iterator cend() const; (since C++11) Returns an iterator to the element following the last element of the container. This element acts as a placeholder; attempting to access it results in undefined behavior. Parameters (none). Return value Iterator to the element following the last element. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. See also begin

std::list::empty

bool empty() const; Checks if the container has no elements, i.e. whether begin() == end(). Parameters (none). Return value true if the container is empty, false otherwise. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Example The following code uses empty to check if a std::list<int> contains any elements: #include <list> #include <iostream> int main() { std::list<int> numbers; s

std::list::emplace_front

template< class... Args > void emplace_front( Args&&... args ); (since C++11) Inserts a new element to the beginning of the container. The element is constructed through std::allocator_traits::construct, which typically uses placement-new to construct the element in-place at the location provided by the container. The arguments args... are forwarded to the constructor as std::forward<Args>(args).... No iterators or references are invalidated. Parameters args -

std::list::emplace_back

template< class... Args > void emplace_back( Args&&... args ); (since C++11) Appends a new element to the end of the container. The element is constructed through std::allocator_traits::construct, which typically uses placement-new to construct the element in-place at the location provided by the container. The arguments args... are forwarded to the constructor as std::forward<Args>(args).... No iterators or references are invalidated. Parameters args - argum

std::list::emplace

template< class... Args > iterator emplace( const_iterator pos, Args&&... args ); (since C++11) Inserts a new element into the container directly before pos. The element is constructed through std::allocator_traits::construct, which typically uses placement-new to construct the element in-place at a location provided by the container. The arguments args... are forwarded to the constructor as std::forward<Args>(args).... No iterators or references are invalidated.