std::flat_m...p::contains(3)
π¦ std::flat_m...p::contains(3) π¦
okay so this is the C++ Standard Libary manual, and todayβs main character is std::flat_multimap::contains β page std::flat_m...p::contains(3). itβs giving βdo I know this key or not?β energy, and honestly? iconic. π
πΈ NAME πΈ
std::flat_multimap::contains β std::flat_multimap::contains
β¨ Synopsis β¨
bool contains( const Key& key ) const; (1) (since C++23)
template< class K > (2) (since C++23)
bool contains( const K& x ) const;
(1)β checks if there is an element with key equivalent tokeyin the container. π(2)β checks if there is an element with key that compares equivalent to the valuex.
this overload participates in overload resolution only if the qualified-id Compare::is_transparent is valid and denotes a type. it allows calling this function without constructing an instance of Key. no cap, thatβs the transparent-comparator flex. π«Ά
π Parameters π
keyβ key value of the element to search forxβ a value of any type that can be transparently compared with a key
π Return value π
true if there is such an element, otherwise false.
π¦ Complexity π¦
Logarithmic in the size of the container. logarithmic, bestie β not a whole scan, weβre bougie like that. β¨
π Example π
// Run this code
#include <iostream>
#include <flat_map>
int main()
{
std::flat_multimap<int, char> example{{1, 'a'}, {2, 'b'}};
for (int x : {2, 5})
if (example.contains(x))
std::cout << x << ": Found\n";
else
std::cout << x << ": Not found\n";
}
β Output β
2: Found
5: Not found
π See also π
findβ finds element with specific key (public member function)countβ returns the number of elements matching specific key (public member function)equal_rangeβ returns range of elements matching a specific key (public member function)
thatβs the whole page, bestie π β source is http://cppreference.com, the version/date stamp is 2024.06.10, and the page is std::flat_m...p::contains(3). mwah π«Ά
π¦ 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