On 21/09/16 14:48 +0100, Jonathan Wakely wrote:
This implements container node extraction/insertion, and merging. The
patch includes Debug Mode support and pretty printers for the node
handles.

This adds some assertions to check for the mistake of trying to
extract the end iterator.

Tested powerpc64le-linux, comitted to trunk.


commit 1073944c341d022d501c07b7881e7c6ead0b1fca
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Sep 26 10:35:52 2016 +0100

    Add assertions to extract(const_iterator) functions
    
    	* include/bits/stl_map.h (map::extract(const_iterator)): Assert that
    	iterator is not past-the-end.
    	* include/bits/stl_multimap.h (multimap::extract(const_iterator)):
    	Likewise.
    	* include/bits/stl_multiset.h (multiset::extract(const_iterator)):
    	Likewise.
    	* include/bits/stl_set.h (set::extract(const_iterator)): Likewise.
    	* include/bits/unordered_map.h (unordered_map::extract(const_iterator))
    	(unordered_multimap::extract(const_iterator)): Likewise.
    	* include/bits/unordered_set.h (unordered_set::extract(const_iterator))
    	(unordered_multiset::extract(const_iterator)): Likewise.

diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h
index f9482e2..9a0454a 100644
--- a/libstdc++-v3/include/bits/stl_map.h
+++ b/libstdc++-v3/include/bits/stl_map.h
@@ -605,7 +605,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h
index 2b56824..c794b9b 100644
--- a/libstdc++-v3/include/bits/stl_multimap.h
+++ b/libstdc++-v3/include/bits/stl_multimap.h
@@ -606,7 +606,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h
index d7312df..d3219eb 100644
--- a/libstdc++-v3/include/bits/stl_multiset.h
+++ b/libstdc++-v3/include/bits/stl_multiset.h
@@ -549,7 +549,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h
index fd96dd4..140db39 100644
--- a/libstdc++-v3/include/bits/stl_set.h
+++ b/libstdc++-v3/include/bits/stl_set.h
@@ -565,7 +565,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h
index ab8a762..6776090 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -421,7 +421,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
@@ -1534,7 +1537,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h
index e5bb2be..9905257 100644
--- a/libstdc++-v3/include/bits/unordered_set.h
+++ b/libstdc++-v3/include/bits/unordered_set.h
@@ -482,7 +482,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
@@ -1190,7 +1193,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+	__glibcxx_assert(__pos != end());
+	return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type

Reply via email to