Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / graph / detail / d_ary_heap.hpp
index ba58647..cf930fc 100644 (file)
 #include <boost/shared_array.hpp>
 #include <boost/property_map/property_map.hpp>
 
+// WARNING: it is not safe to copy a d_ary_heap_indirect and then modify one of
+// the copies.  The class is required to be copyable so it can be passed around
+// (without move support from C++11), but it deep-copies the heap contents yet
+// shallow-copies the index_in_heap_map.
+
 namespace boost {
 
   // Swap two elements in a property map without assuming they model
@@ -121,18 +126,21 @@ namespace boost {
     }
 
     Value& top() {
+      BOOST_ASSERT (!this->empty());
       return data[0];
     }
 
     const Value& top() const {
+      BOOST_ASSERT (!this->empty());
       return data[0];
     }
 
     void pop() {
+      BOOST_ASSERT (!this->empty());
       put(index_in_heap, data[0], (size_type)(-1));
       if (data.size() != 1) {
         data[0] = data.back();
-        put(index_in_heap, data[0], 0);
+        put(index_in_heap, data[0], (size_type)(0));
         data.pop_back();
         preserve_heap_property_down();
         verify_heap();