std::multimap::empty(3)
πΈ NAME πΈ
std::multimap::empty - std::multimap::empty β okay so bestie, welcome to the std::multimap::empty(3) page from the C++ Standard Library. This is the std::multimap member that checks if the container has no elements. Literally the vibe check for your multimap.
β¨ Synopsis β¨
Here's the signature glow-up across C++ versions β keep the annotations, they matter:
bool empty() const; (until C++11)
bool empty() const noexcept; (since C++11)
(until C++20)
[[nodiscard]] bool empty() const noexcept; (since C++20)
So what does it do? It checks if the container has no elements, i.e. whether begin() == end(). No cap.
π Parameters π
(none)β it takes zero parameters, bestie. Not a single one.
π Return value π
trueif the container is empty.falseotherwise.
π¦ Complexity π¦
Constant. That's it. The vibe check is constant.
π Example π
The following code uses empty to check if a std::multimap<int, int> contains any elements:
// Run this code
#include <iostream>
#include <map>
#include <utility>
int main()
{
std::multimap<int,int> numbers;
std::cout << std::boolalpha;
std::cout << "Initially, numbers.empty(): " << numbers.empty() <<
'\n';
numbers.emplace(42, 13);
numbers.insert(std::make_pair(13317, 123));
std::cout << "After adding elements, numbers.empty(): " <<
numbers.empty() << '\n';
}
β¨ Output β¨
Initially, numbers.empty(): true
After adding elements, numbers.empty(): false
π See also π
sizeβ returns the number of elements (public member function)emptyβ checks whether the container is empty (C++17) (function template)
π source/version: http://cppreference.com Β· 2024.06.10 β that's the whole page, bestie. Now go check if your multimap is empty and slay, periodt. π
π¦ 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