[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/container/list/size [Back]  [Original]

std::list::size cppreference.com
cppreference.com

std::list::size

cppreference.com

<metanoindex/>

<tbody> </tbody>
size_type size() const;

Returns the number of elements in the container, i.e. std::distance(begin(), end()).

()

:
the number of elements in the container
Google.
. .

noexcept:  
noexcept
  

Constant or linear ( C++11)

Constant ( C++11)

The following code uses size to display the number of elements in a std::list<int>:

#include <list>
#include <iostream>

int main()
{
    std::list<int> nums {1, 3, 5, 7};

    std::cout << "nums contains " << nums.size() << " elements.\n";
}

:

nums contains 4 elements.

.

,
(public -) []

(public -) []

(public -) []

Web Proxy Viewer  |  New URL  |  Original Page