std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>::contains

  1. Checks if there is an element with key equivalent to key in the container.

# Declarations

bool contains( const Key& key ) const;

(since C++20)

template< class K >
bool contains( const K& x ) const;

(since C++20)

# Parameters

# Return value

true if there is such an element, otherwise false.

# Example

#include <iostream>
#include <unordered_map>
 
int main()
{
    std::unordered_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";
}

# See also