std::set::size(3)
π NAME π
Welcome to std::set::size(3), straight from the C++ Standard Libary β yes, thatβs the spelling on the page, and Iβm keeping it exactly as-is, no cap π
std::set::size β okay so the NAME line literally says std::set::size and then std::set::size again. Thatβs the name, bestie, no plot twist π
π¦ Synopsis π¦
size_type size() const; (noexcept since C++11)
Returns the number of elements in the container, i.e. std::distance(begin(), end()). Since C++11 itβs noexcept, periodt β¨
πΈ Parameters πΈ
(none) β literally zero parameters. not a single argument. the void of parameters. π³οΈβ¨
π Return value π
The number of elements in the container. Thatβs it, bestie β the return value is giving βcount of elementsβ and nothing else π
β Complexity β
Constant. No cap, itβs constant complexity, and thatβs the whole vibe π
π Example π
The following code uses size to display the number of elements in a std::set<int>:
// Run this code
#include <iostream>
#include <set>
int main()
{
std::set<int> nums{1, 3, 5, 7};
std::cout << "nums contains " << nums.size() << " elements.\n";
}
Output:
nums contains 4 elements.
π See also π
The original table is a lil scrambled, but every piece is right here, iykyk:
emptyβ checks whether the container is empty (public member function)max_sizeβ returns the maximum possible number of elements (public member function)sizeβ(C++17)returns the size of a container or array(function template)ssizeβ(C++20)returns the size of a container or array(function template)
mwah π source/date from the footer: http://cppreference.com, 2024.06.10 β catch you in the next one, 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