std::flat_map::contains(3)
π NAME π
std::flat_map::contains - std::flat_map::contains
okay so bestie, welcome to the std::flat_map::contains(3) page from the C++ Standard Libary β and yes, the manual name is literally C++ Standard Libary, spelling and all. It's giving "self-titled debut album" and we're keeping it exactly as it appears π
β¨
π¦ Synopsis π¦
Here are the two overloads, both marked since C++23 β no cap, this is the whole lineup:
bool contains( const Key& key ) const; (1) (since C++23)
template< class K > (2) (since C++23)
bool contains( const K& x ) const;
- Checks if there is an element with key equivalent to
keyin the container. - Checks if there is an element with key that compares equivalent to the value
x. This overload participates in overload resolution only if the qualified-idCompare::is_transparentis valid and denotes a type. It allows calling this function without constructing an instance ofKey.
π 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. That's the whole answer β found/not found, iconic binary energy π
π₯ Complexity π₯
Logarithmic in the size of the container. Short, sweet, and mathematically slaying.
πΈ Example πΈ
Run this code, bestie:
// Run this code
#include <iostream>
#include <flat_map>
int main()
{
std::flat_map<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)
π«Ά source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::flat_map::contains(3) β mwah, bestie, that's the whole page, go check your keys π
β¨
π¦ 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