std::flat_set<Key,Compare,KeyContainer>::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++23)

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

(since C++23)

# Parameters

# Return value

true if there is such an element, otherwise false.

# Example

#include <iostream>
#include <flat_set>
 
int main()
{
    std::flat_set<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