]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/bits/stl_set.h
P0458R2 Checking for Existence of an Element in Associative Containers
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / stl_set.h
index 4192526502568d63f10bf440890070a399f88e2d..ee959d5fc1e93e21084547e9f13df8837ce94701 100644 (file)
@@ -757,6 +757,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 #endif
       //@}
 
+#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 an element with the specified key.
+       */
+      bool
+      contains(const key_type& __x) const
+      { return _M_t.find(__x) != _M_t.end(); }
+
+      template<typename _Kt>
+       auto
+       contains(const _Kt& __x) const
+       -> decltype(_M_t._M_find_tr(__x), void(), true)
+       { return _M_t._M_find_tr(__x) != _M_t.end(); }
+      //@}
+#endif
+
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 214.  set::find() missing const overload
       //@{