std::map::size(3)
okay bestie, welcome to std::map::size(3) from the C++ Standard Libary β manual name folded in right here, typo preserved because details are details π
β¨
β¨ NAME β¨
std::map::size β std::map::size (yes bestie, the name is the name, it's giving self-referential main character energy π)
π¦ Synopsis π¦
size_type size() const; (noexcept since C++11)
Returns the number of elements in the container, i.e. std::distance(begin(), end()). That's the whole synopsis tea β
πΈ Parameters πΈ
(none) β she takes zero parameters, low-maintenance icon behavior π«Ά
π Return value π
The number of elements in the container. That's the whole answer, no cap π
β‘ Complexity β‘
Constant. The page says constant, bestie β that's the vibe check, and it passes π₯
π Example π
The following code uses size to display the number of elements in a std::map:
// Run this code
#include <iostream>
#include <map>
int main()
{
std::map<int,char> nums{{1, 'a'}, {3, 'b'}, {5, 'c'}, {7, 'd'}};
std::cout << "nums contains " << nums.size() << " elements.\n";
}
Output:
nums contains 4 elements.
π See also π
emptyβ checks whether the container is empty (public member function)max_sizeβ returns the maximum possible number of elements (public member function)sizeβ baresizeentry from the original See also block, standing right here with no extra description attachedssizeβ returns the size of a container or array(C++17)(function template)(C++20)
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page tag: std::map::size(3) β bye bestie, go count your elements and slay ππ
π¦ 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