std::list<T,Allocator>:: size
From cppreference.net
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::list
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides (C++17) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
size_type size
(
)
const
;
|
(noexcept seit C++11)
(constexpr seit C++26) |
|
Gibt die Anzahl der Elemente im Container zurück.
Inhaltsverzeichnis |
Rückgabewert
std:: distance ( begin ( ) , end ( ) )
Komplexität
|
Konstant oder linear. |
(bis C++11) |
|
Konstant. |
(seit C++11) |
Beispiel
Der folgende Code verwendet
size
, um die Anzahl der Elemente in einer
std::list
anzuzeigen:
Diesen Code ausführen
Ausgabe:
nums contains 4 elements.
Siehe auch
|
prüft, ob der Container leer ist
(öffentliche Elementfunktion) |
|
|
gibt die maximal mögliche Anzahl von Elementen zurück
(öffentliche Elementfunktion) |
|
|
ändert die Anzahl der gespeicherten Elemente
(öffentliche Elementfunktion) |
|
|
(C++17)
(C++20)
|
gibt die Größe eines Containers oder Arrays zurück
(Funktionstemplate) |