]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/debug/set.h
Implement C++17 node extraction and insertion (P0083R5)
[thirdparty/gcc.git] / libstdc++-v3 / include / debug / set.h
index ede4103acd8c919b3b79a603f632a4c39c4fd40a..8937638445824e9d41c3d813b4c4b39d22520e2a 100644 (file)
@@ -296,6 +296,51 @@ namespace __debug
       { _Base::insert(__l); }
 #endif
 
+#if __cplusplus > 201402L
+      using node_type = typename _Base::node_type;
+
+      struct insert_return_type
+      {
+       bool inserted;
+       iterator position;
+       node_type node;
+      };
+
+      node_type
+      extract(const_iterator __position)
+      {
+       __glibcxx_check_erase(__position);
+       this->_M_invalidate_if(_Equal(__position.base()));
+       return _Base::extract(__position.base());
+      }
+
+      node_type
+      extract(const key_type& __key)
+      {
+       const auto __position = find(__key);
+       if (__position != end())
+         return extract(__position);
+       return {};
+      }
+
+      insert_return_type
+      insert(node_type&& __nh)
+      {
+       auto __ret = _Base::insert(std::move(__nh));
+       iterator __pos = iterator(__ret.position, this);
+       return { __ret.inserted, __pos, std::move(__ret.node) };
+      }
+
+      iterator
+      insert(const_iterator __hint, node_type&& __nh)
+      {
+       __glibcxx_check_insert(__hint);
+       return iterator(_Base::insert(__hint.base(), std::move(__nh)), this);
+      }
+
+      using _Base::merge;
+#endif // C++17
+
 #if __cplusplus >= 201103L
       iterator
       erase(const_iterator __position)