diff options
author | Paolo Carlini <pcarlini@suse.de> | 2006-04-10 10:05:51 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2006-04-10 10:05:51 +0000 |
commit | 9f889fcf528e9c42a0c17c8bc63afe89f749f786 (patch) | |
tree | 5b60683799d029dd82b0d0e77535ce75aa2c309d | |
parent | cf26aa89100a9340eaae73c3beee6dd791cb7777 (diff) | |
download | gcc-9f889fcf528e9c42a0c17c8bc63afe89f749f786.zip gcc-9f889fcf528e9c42a0c17c8bc63afe89f749f786.tar.gz gcc-9f889fcf528e9c42a0c17c8bc63afe89f749f786.tar.bz2 |
DR 538, [Ready]
2006-04-10 Paolo Carlini <pcarlini@suse.de>
DR 538, [Ready]
* include/bits/stl_algo.h (__unique_copy(,,, input_iterator_tag,
output_iterator_tag), and predicated counterpart): Revert to the
algorithm pre-DR 241, i.e., value_type of InputIterator is now
required to be Assignable too.
* testsuite/25_algorithms/unique_copy/3.cc: Remove.
* docs/html/ext/howto.html: Add an entry for DR 538.
From-SVN: r112818
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/docs/html/ext/howto.html | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 44 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/unique_copy/3.cc | 93 |
4 files changed, 38 insertions, 117 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b0f2a3d..b03febe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2006-04-10 Paolo Carlini <pcarlini@suse.de> + + DR 538, [Ready] + * include/bits/stl_algo.h (__unique_copy(,,, input_iterator_tag, + output_iterator_tag), and predicated counterpart): Revert to the + algorithm pre-DR 241, i.e., value_type of InputIterator is now + required to be Assignable too. + * testsuite/25_algorithms/unique_copy/3.cc: Remove. + * docs/html/ext/howto.html: Add an entry for DR 538. + 2006-03-29 Benjamin Kosnik <bkoz@redhat.com> * testsuite/data/sgetn.txt: Correct copyright holder. diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html index 7fb2a6a..f937a14 100644 --- a/libstdc++-v3/docs/html/ext/howto.html +++ b/libstdc++-v3/docs/html/ext/howto.html @@ -573,6 +573,14 @@ <dd>Add <code>data()</code> to <code>std::vector</code> and <code>at(const key_type&)</code> to <code>std::map</code>. </dd> + + <dt><a href="lwg-active.html#538">538</a>: + <em>DR 538. 241 again: Does unique_copy() require CopyConstructible + and Assignable?</em> + </dt> + <dd>In case of input_iterator/output_iterator rely on Assignability of + input_iterator' value_type. + </dd> <!-- <dt><a href="lwg-defects.html#"></a>: <em></em> diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index fe94f71..7c54f50 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -1340,18 +1340,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) input_iterator_tag, output_iterator_tag) { // concept requirements -- taken care of in dispatching function - *__result = *__first; - while (true) - { - typename - iterator_traits<_InputIterator>::value_type __value = *__first; - - if (++__first == __last) - break; - - if (!(__value == *__first)) - *++__result = *__first; - } + typename iterator_traits<_InputIterator>::value_type __value = *__first; + *__result = __value; + while (++__first != __last) + if (!(__value == *__first)) + { + __value = *__first; + *++__result = __value; + } return ++__result; } @@ -1427,18 +1423,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typename iterator_traits<_InputIterator>::value_type, typename iterator_traits<_InputIterator>::value_type>) - *__result = *__first; - while (true) - { - typename - iterator_traits<_InputIterator>::value_type __value = *__first; - - if (++__first == __last) - break; - - if (!__binary_pred(__value, *__first)) - *++__result = *__first; - } + typename iterator_traits<_InputIterator>::value_type __value = *__first; + *__result = __value; + while (++__first != __last) + if (!__binary_pred(__value, *__first)) + { + __value = *__first; + *++__result = __value; + } return ++__result; } @@ -1485,6 +1477,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * @if maint * _GLIBCXX_RESOLVE_LIB_DEFECTS * DR 241. Does unique_copy() require CopyConstructible and Assignable? + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 538. 241 again: Does unique_copy() require CopyConstructible and + * Assignable? * @endif */ template<typename _InputIterator, typename _OutputIterator> diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/3.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/3.cc deleted file mode 100644 index 2245821..0000000 --- a/libstdc++-v3/testsuite/25_algorithms/unique_copy/3.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2006 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 -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -// USA. - -// 25.2.8 [lib.alg.unique] - -#include <algorithm> -#include <testsuite_hooks.h> -#include <testsuite_iterators.h> - -using __gnu_test::test_container; -using __gnu_test::input_iterator_wrapper; -using __gnu_test::output_iterator_wrapper; -using std::unique_copy; -using std::equal_to; - -struct no_assign -{ - int const x; - no_assign() : x(23) { } - no_assign(int val) : x(val) { } - operator int() const { return x; } -}; - -typedef test_container<no_assign, input_iterator_wrapper> Icontainer; -typedef test_container<int, output_iterator_wrapper> Ocontainer; - -no_assign array1[] = {0, 0, 0, 1, 1, 1}; -int array2[2]; - -void -test1() -{ - bool test __attribute__((unused)) = true; - Icontainer con1(array1, array1); - Ocontainer con2(array2, array2); - VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2 ); -} - -void -test2() -{ - bool test __attribute__((unused)) = true; - Icontainer con1(array1, array1 + 6); - Ocontainer con2(array2, array2 + 2); - VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr - == array2 + 2 ); - VERIFY( array2[0] == 0 && array2[1] == 1 ); -} - -void -test3() -{ - bool test __attribute__((unused)) = true; - Icontainer con1(array1, array1); - Ocontainer con2(array2, array2); - VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin(), - equal_to<int>()).ptr == array2 ); -} - -void -test4() -{ - bool test __attribute__((unused)) = true; - Icontainer con1(array1, array1 + 6); - Ocontainer con2(array2, array2 + 2); - VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin(), - equal_to<int>()).ptr == array2 + 2 ); - VERIFY( array2[0] == 0 && array2[1] == 1 ); -} - -int -main() -{ - test1(); - test2(); - test3(); - test4(); -} |