DR 538, [Ready]
authorPaolo Carlini <pcarlini@suse.de>
Mon, 10 Apr 2006 10:05:51 +0000 (10:05 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 10 Apr 2006 10:05:51 +0000 (10:05 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/docs/html/ext/howto.html
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/testsuite/25_algorithms/unique_copy/3.cc [deleted file]

index b0f2a3d..b03febe 100644 (file)
@@ -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.
index 7fb2a6a..f937a14 100644 (file)
     <dd>Add <code>data()</code> to <code>std::vector</code> and
         <code>at(const key_type&amp;)</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>
index fe94f71..7c54f50 100644 (file)
@@ -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 (file)
index 2245821..0000000
+++ /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();
-}