From: François Dumont Date: Tue, 5 Jun 2018 05:47:44 +0000 (+0000) Subject: 2018-06-05 François Dumont X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d31238cfde0b9e89a4b24e5d37c81aa55d54494b;p=gcc.git 2018-06-05 François Dumont * 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2a201ae11c2..0fa14c1f0e2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2018-06-05 François Dumont + + * 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 PR libstdc++/85930 diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 753ebb7a09c..e68ba7c1807 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -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); diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index 56c4ac574bb..159ee27a5d3 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -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 _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 */ - diff --git a/libstdc++-v3/include/ext/memory b/libstdc++-v3/include/ext/memory index c5d526e7ef9..fcc49487a80 100644 --- a/libstdc++-v3/include/ext/memory +++ b/libstdc++-v3/include/ext/memory @@ -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() { }