std::list::size(3)
π
std::list::size β C++ Standard Libary main character energy
okay so this is the page for std::list::size(3), straight outta the C++ Standard Libary, and yes bestie it is literally about std::list::size. no cap, we're getting into it. π«Ά
β¨ NAME β¨
std::list::size β std::list::size
likeβ¦ that's the name, that's the function, that's the vibe. periodt. π
π¦ Synopsis π¦
Two eras, bestie β the before-times and the noexcept glow-up:
size_type size() const; (until C++11)
size_type size() const noexcept; (since C++11)
It returns the number of elements in the container, i.e. std::distance(begin(), end()). that's the whole assignment. β¨
π Parameters π
(none)
absolutely none, bestie. not a single argument. she takes no notes. π
π Return value π
The number of elements in the container.
that's it. that's the tea. the count. π
π₯ Complexity π₯
- Until C++11: Constant or linear.
- Since C++11: Constant.
so modern you is eating good, fr fr. π₯
π Example π
The following code uses size to display the number of elements in a std::list:
// Run this code
#include <iostream>
#include <list>
int main()
{
std::list<int> nums{1, 3, 5, 7};
std::cout << "nums contains " << nums.size() << " elements.\n";
}
π Output π
nums contains 4 elements.
slay. four little ints, one iconic little output. π
π See also π
emptyβ checks whether the container is empty (public member function)max_sizeβ returns the maximum possible number of elements (public member function)resizeβ changes the number of elements stored (public member function)
mwah π β source/version: http://cppreference.com Β· date: 2024.06.10 Β· manual: std::list::size(3). bestie, you understood the assignment. π§ββοΈπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms