std::multimap::size(3)

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

πŸ’– NAME πŸ’–

std::multimap::size - std::multimap::size β€” yes bestie, the NAME section in the original literally repeats itself, and honestly? Iconic. This page is from the C++ Standard Libary manual (typo is original, I’m obsessed 😭).


✨ Synopsis ✨

Here’s the signature, copied exactly with the (noexcept since C++11) note:

size_type size() const;  (noexcept since C++11)

This returns the number of elements in the container, i.e. std::distance(begin(), end()).

🌸 Parameters 🌸

(none) β€” no parameters, bestie. Zero. None. The parameter vibe check is empty.

πŸŽ€ Return value πŸŽ€

The number of elements in the container.

πŸ¦‹ Complexity πŸ¦‹

Constant. That’s it β€” the original just says Constant, so we’re keeping that exact energy.

πŸ”₯ Example πŸ”₯

The following code uses size to display the number of elements in a std::multimap:

// Run this code

#include <iostream>
#include <map>

int main()
{
    std::multimap<int,char> nums{{1, 'a'}, {3, 'b'}, {5, 'c'}, {7,
'd'}};

    std::cout << "nums contains " << nums.size() << " elements.\n";
}
The line break after {7, is from the original man page, so we’re keeping the original code energy. 🫢

⭐ 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 β€” the original lists this one bare, with no description attached; keeping it here so no reference goes missing 😭
  • ssize β€” returns the size of a container or array (function template); the original also has (C++17) and (C++20) markers hanging out in this See also area, and yes they’re staying

πŸ’– That’s the whole page, bestie. Source/version: http://cppreference.com, dated 2024.06.10. Go count your elements, periodt. πŸ’–

πŸ“¦ where this page comes from