Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libstdc++-v3 / include / bits / stl_heap.h
index f185610..807a8cf 100644 (file)
@@ -1,7 +1,6 @@
 // Heap implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-// 2011 Free Software Foundation, Inc.
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -292,8 +291,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __glibcxx_requires_valid_range(__first, __last);
       __glibcxx_requires_heap(__first, __last);
 
-      --__last;
-      std::__pop_heap(__first, __last, __last);
+      if (__last - __first > 1)
+       {
+         --__last;
+         std::__pop_heap(__first, __last, __last);
+       }
     }
 
   template<typename _RandomAccessIterator, typename _Distance,
@@ -364,8 +366,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __glibcxx_requires_non_empty_range(__first, __last);
       __glibcxx_requires_heap_pred(__first, __last, __comp);
 
-      --__last;
-      std::__pop_heap(__first, __last, __last, __comp);
+      if (__last - __first > 1)
+       {
+         --__last;
+         std::__pop_heap(__first, __last, __last, __comp);
+       }
     }
 
   /**
@@ -502,7 +507,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
     }
 
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#if __cplusplus >= 201103L
   /**
    *  @brief  Search the end of a heap.
    *  @param  __first  Start of range.