// 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
__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,
__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);
+ }
}
/**
}
}
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#if __cplusplus >= 201103L
/**
* @brief Search the end of a heap.
* @param __first Start of range.