2018-06-05 François Dumont <fdumont@gcc.gnu.org>
authorFrançois Dumont <fdumont@gcc.gnu.org>
Tue, 5 Jun 2018 05:47:44 +0000 (05:47 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Tue, 5 Jun 2018 05:47:44 +0000 (05:47 +0000)
* include/bits/stl_tempbuf.h
(_Temporary_buffer(_FwdIte, _FwdIte)): Delete, replaced by...
(_Temporary_buffer(_FwdIte, size_type)): ...this, new.
* include/ext/memory (temporary_buffer<>(_FwdIte, _FwdIte)): Adapt.
* include/bits/stl_algo.h (__stable_partition): Adapt.
(__inplace_merge): Adapt.
(__stable_sort): Adapt.

From-SVN: r261181

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/bits/stl_tempbuf.h
libstdc++-v3/include/ext/memory

index 2a201ae11c2b825ddecb85401f619ff4b421a0bf..0fa14c1f0e2857be68db79b71eaa2fff37442f5b 100644 (file)
@@ -1,3 +1,13 @@
+2018-06-05  François Dumont  <fdumont@gcc.gnu.org>
+
+       * include/bits/stl_tempbuf.h
+       (_Temporary_buffer(_FwdIte, _FwdIte)): Delete, replaced by...
+       (_Temporary_buffer(_FwdIte, size_type)): ...this, new.
+       * include/ext/memory (temporary_buffer<>(_FwdIte, _FwdIte)): Adapt.
+       * include/bits/stl_algo.h (__stable_partition): Adapt.
+       (__inplace_merge): Adapt.
+       (__stable_sort): Adapt.
+
 2018-06-04  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/85930
index 753ebb7a09c6bc7c30d4bf3a2cdd0a2e637a0ef4..e68ba7c1807cefd9a76b7b7e7c01e3c2d693033c 100644 (file)
@@ -1621,7 +1621,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename iterator_traits<_ForwardIterator>::difference_type
        _DistanceType;
 
-      _Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first, __last);
+      _Temporary_buffer<_ForwardIterator, _ValueType>
+       __buf(__first, std::distance(__first, __last));
       return
        std::__stable_partition_adaptive(__first, __last, __pred,
                                         _DistanceType(__buf.requested_size()),
@@ -2540,7 +2541,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const _DistanceType __len2 = std::distance(__middle, __last);
 
       typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf;
-      _TmpBuf __buf(__first, __last);
+      _TmpBuf __buf(__first, __len1 + __len2);
 
       if (__buf.begin() == 0)
        std::__merge_without_buffer
@@ -4998,7 +4999,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
        _DistanceType;
 
       typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf;
-      _TmpBuf __buf(__first, __last);
+      _TmpBuf __buf(__first, std::distance(__first, __last));
 
       if (__buf.begin() == 0)
        std::__inplace_stable_sort(__first, __last, __comp);
index 56c4ac574bb079ec548203e922fecc1b121e4d70..159ee27a5d39e818151dc9c57bea87b988a884e9 100644 (file)
@@ -158,9 +158,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       /**
        * Constructs a temporary buffer of a size somewhere between
-       * zero and the size of the given range.
+       * zero and the given length.
        */
-      _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last);
+      _Temporary_buffer(_ForwardIterator __seed, size_type __original_len);
 
       ~_Temporary_buffer()
       {
@@ -241,9 +241,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _ForwardIterator, typename _Tp>
     _Temporary_buffer<_ForwardIterator, _Tp>::
-    _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
-    : _M_original_len(std::distance(__first, __last)),
-      _M_len(0), _M_buffer(0)
+    _Temporary_buffer(_ForwardIterator __seed, size_type __original_len)
+    : _M_original_len(__original_len), _M_len(0), _M_buffer(0)
     {
       __try
        {
@@ -253,7 +252,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          _M_len = __p.second;
          if (_M_buffer)
            std::__uninitialized_construct_buf(_M_buffer, _M_buffer + _M_len,
-                                              __first);
+                                              __seed);
        }
       __catch(...)
        {
@@ -268,4 +267,3 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
 #endif /* _STL_TEMPBUF_H */
-
index c5d526e7ef9840f2df9eeef421d7685369bb03f6..fcc49487a8003aa0e9cebf7fc317d2d4b3436a3a 100644 (file)
@@ -184,7 +184,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       /// Requests storage large enough to hold a copy of [first,last).
       temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
-      : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { }
+      : _Temporary_buffer<_ForwardIterator, _Tp>(__first,
+                                                std::distance(__first, __last))
+      { }
       
       /// Destroys objects and frees storage.
       ~temporary_buffer() { }