libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ size()

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

Returns the number of elements in the list.

Definition at line 1586 of file stl_list.h.

1587 {
1588#if _GLIBCXX_USE_CXX11_ABI
1589 return this->_M_get_size(); // return the stored size
1590#else
1591 return std::distance(begin(), end()); // count the number of nodes
1592#endif
1593 }
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
iterator begin() noexcept
Definition stl_list.h:1457
iterator end() noexcept
Definition stl_list.h:1477
size_t _M_get_size() const
Definition stl_list.h:797

Referenced by _M_resize_pos(), std::operator<=>(), remove(), remove_if(), unique(), and unique().

Here is the caller graph for this function: