std::flat_map::size(3)
π NAME π
std::flat_map::size β std::flat_map::size β okay bestie, this is the std::flat_map::size(3) page from the C++ Standard Libary manual, and it's giving βhow many elements are we carrying?β energy π
πΈ Synopsis πΈ
size_type size() const noexcept; (since C++23)
Returns the number of elements in the container adaptor. Equivalent to return c.keys.size(). No cap β¨
π Parameters π
(none) β literally none, not a single parameter in sight π«Ά
π¦ Return value π¦
The number of elements in the container adaptor. That's the whole tea β
β Complexity β
Constant. Iconic, efficient, no drama π«
π₯ Example π₯
The following code uses size to display the number of elements in a std::flat_map:
// Run this code
#include <iostream>
#include <flat_map>
int main()
{
std::flat_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 adaptor is empty (public member function)sizeβ returns the size of a container or array (C++17) (function template)ssizeβ returns the size of a container or array (C++20) (function template)max_sizeβ returns the maximum possible number of elements (public member function)
source/version: http://cppreference.com πΈ date: 2024.06.10 β mwah, bestie π
π¦ 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