]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/bits/unordered_set.h
P0458R2 Checking for Existence of an Element in Associative Containers
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / unordered_set.h
index c9ac4ad57e3d8e5b960288cc123fa6a82ca8524c..4c49ae945fcd321ef1437c8f96175f22dd742406 100644 (file)
@@ -667,6 +667,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       count(const key_type& __x) const
       { return _M_h.count(__x); }
 
+#if __cplusplus > 201703L
+      /**
+       *  @brief  Finds whether an element with the given key exists.
+       *  @param  __x  Key of elements to be located.
+       *  @return  True if there is any element with the specified key.
+       */
+      bool
+      contains(const key_type& __x) const
+      { return _M_h.find(__x) != _M_h.end(); }
+#endif
+
       //@{
       /**
        *  @brief Finds a subsequence matching given key.
@@ -1445,6 +1456,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       count(const key_type& __x) const
       { return _M_h.count(__x); }
 
+#if __cplusplus > 201703L
+      /**
+       *  @brief  Finds whether an element with the given key exists.
+       *  @param  __x  Key of elements to be located.
+       *  @return  True if there is any element with the specified key.
+       */
+      bool
+      contains(const key_type& __x) const
+      { return _M_h.find(__x) != _M_h.end(); }
+#endif
+
       //@{
       /**
        *  @brief Finds a subsequence matching given key.