std::multiset::size(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

Okay so this is std::multiset::size(3), folded in from the C++ Standard Libary manual β€” yes bestie, that's the manual name right there, typo and all 😭.

The NAME section is literally:

std::multiset::size - std::multiset::size

No cap, that's what it says. Moving on, because the rest is where the actual tea is β˜•βœ¨.

πŸ¦‹ Synopsis πŸ¦‹

Here's the signature, exactly:

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 vibe: it tells you how many things are in there πŸ’….

🫢 Parameters 🫢

(none) β€” literally none, bestie. It takes no arguments. Zero. Nada. The audacity, honestly πŸŽ€.

πŸ’œ Return value πŸ’œ

The number of elements in the container. That's it. That's the answer. Iconic behavior 🌟.

⚑ Complexity ⚑

Constant. Not even playing. It does not scale with the container size, it's just constant energy ⚑✨.

🌸 Example 🌸

The following code uses size to display the number of elements in a std::multiset<int>:

// Run this code

#include <iostream>
#include <set>

int main()
{
    std::multiset<int> nums{1, 3, 5, 7};

    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
  • ssize β€” returns the size of a container or array (C++17) (function template) (C++20)

πŸ’Œ That's the whole page, bestie! Source/version/date check: http://cppreference.com, 2024.06.10, page std::multiset::size(3). Mwah πŸ’‹πŸ«Ά

πŸ“¦ where this page comes from