std::multiset<Key,Compare,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 <set>
 
int main()
{
    std::multiset<int> example{1, 2, 3, 4};
 
    for (int x : {2, 5})
        if (example.contains(x))
            std::cout << x << ": Found\n";
        else
            std::cout << x << ": Not found\n";
}

# See also