[multiple changes]
authorPaolo Carlini <paolo@gcc.gnu.org>
Tue, 24 May 2005 10:58:22 +0000 (10:58 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 24 May 2005 10:58:22 +0000 (10:58 +0000)
2005-05-24  Jonathan Wakely  <redi@gcc.gnu.org>

* include/debug/string (class basic_string): Add missing
default template arguments; provide typedefs for char
and wchar_t.
(operator[]): Allow s[s.size()] in debug mode, but not
pedantic mode.

2005-05-24  Paolo Carlini  <pcarlini@suse.de>

Port from libstdcxx_so_7-branch:
2005-04-25  Christopher Jefferson  <chris@bubblescope.net>

* include/bits/stl_algo.h (count): Correct concept checks.
(search_n) : Likewise.
* testsuite/25_algorithms/search_n/check_type.cc: New.

* testsuite/testsuite_iterators.h
(random_access_iterator_wrapper::operator+): Move out of
class to external function, and add symmetric version.

2005-03-14  Christopher Jefferson  <chris@bubblescope.net>

* testsuite/testsuite_iterators.h (WritableObject::WritableObject):
Add const.

2005-02-01  Christopher Jefferson  <chris@bubblescope.net>

* testsuite/testsuite_iterators.h (random_access_iterator_wrapper::
operator--): Fix typo.
(OutputContainer::OutputContainer): Correct zeroing array.
(WritableObject::operator==): Fix typo.
        (WritableObject::operator=): make operator= templated
to allow differing types to be assigned.
(WritableObject::operator++): Fix checking if iterator is
written to multiple times.
(random_access_iterator_wrapper::operator+): Add const.
(random_access_iterator_wrapper::operator-): Likewise.
(random_access_iterator_wrapper::operator[]): Add dereference.

From-SVN: r100101

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/debug/string
libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc [new file with mode: 0644]
libstdc++-v3/testsuite/testsuite_iterators.h

index bba5f417cfd8984bfb6f07002e73547e5fcffcfd..e39d577d540c3d2e0a5fcdd7e46f25772fdf8d5e 100644 (file)
@@ -1,3 +1,43 @@
+2005-05-24  Jonathan Wakely  <redi@gcc.gnu.org>
+
+       * include/debug/string (class basic_string): Add missing
+       default template arguments; provide typedefs for char
+       and wchar_t.
+       (operator[]): Allow s[s.size()] in debug mode, but not
+       pedantic mode.
+
+2005-05-24  Paolo Carlini  <pcarlini@suse.de>
+
+       Port from libstdcxx_so_7-branch:
+       2005-04-25  Christopher Jefferson  <chris@bubblescope.net>
+
+       * include/bits/stl_algo.h (count): Correct concept checks.
+       (search_n) : Likewise.
+       * testsuite/25_algorithms/search_n/check_type.cc: New.
+
+       * testsuite/testsuite_iterators.h
+       (random_access_iterator_wrapper::operator+): Move out of
+       class to external function, and add symmetric version.
+
+       2005-03-14  Christopher Jefferson  <chris@bubblescope.net>
+
+       * testsuite/testsuite_iterators.h (WritableObject::WritableObject):
+       Add const.
+       
+       2005-02-01  Christopher Jefferson  <chris@bubblescope.net>
+
+       * testsuite/testsuite_iterators.h (random_access_iterator_wrapper::
+       operator--): Fix typo.
+       (OutputContainer::OutputContainer): Correct zeroing array.
+       (WritableObject::operator==): Fix typo.
+        (WritableObject::operator=): make operator= templated 
+       to allow differing types to be assigned.
+       (WritableObject::operator++): Fix checking if iterator is
+       written to multiple times.
+       (random_access_iterator_wrapper::operator+): Add const.
+       (random_access_iterator_wrapper::operator-): Likewise.
+       (random_access_iterator_wrapper::operator[]): Add dereference.
+
 2005-05-23  Jonathan Wakely  <redi@gcc.gnu.org>
 
        * docs/html/debug.html: Explain that _GLIBXX_DEBUG_PEDANTIC
index 7647ba342f8bf56f2b32da3815be16eef0c5efee..469773cb3fe127056f5f277348474d35bb0994c3 100644 (file)
@@ -413,9 +413,8 @@ namespace std
     {
       // concept requirements
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
-      __glibcxx_function_requires(_EqualityComparableConcept<
-           typename iterator_traits<_InputIterator>::value_type >)
-      __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
+      __glibcxx_function_requires(_EqualOpConcept<
+       typename iterator_traits<_InputIterator>::value_type, _Tp>)
       __glibcxx_requires_valid_range(__first, __last);
       typename iterator_traits<_InputIterator>::difference_type __n = 0;
       for ( ; __first != __last; ++__first)
@@ -627,9 +626,8 @@ namespace std
     {
       // concept requirements
       __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
-      __glibcxx_function_requires(_EqualityComparableConcept<
-           typename iterator_traits<_ForwardIterator>::value_type>)
-      __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
+      __glibcxx_function_requires(_EqualOpConcept<
+       typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
       __glibcxx_requires_valid_range(__first, __last);
 
       if (__count <= 0)
index a91c004e93792b02cd9c0c2f1f88ae3514cc42e8..3893cd2b5f68bcd80b7a5cf58197ad35a25a4b55 100644 (file)
@@ -1,6 +1,6 @@
 // Debugging string implementation -*- C++ -*-
 
-// Copyright (C) 2003
+// Copyright (C) 2003, 2005
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -37,7 +37,8 @@
 
 namespace __gnu_debug
 {
-  template<typename _CharT, typename _Traits, typename _Allocator>
+template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
+            typename _Allocator = std::allocator<_CharT> >
     class basic_string
     : public std::basic_string<_CharT, _Traits, _Allocator>,
       public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
@@ -213,7 +214,16 @@ namespace __gnu_debug
     reference
     operator[](size_type __pos)
     {
+#ifdef _GLIBCXX_DEBUG_PEDANTIC
       __glibcxx_check_subscript(__pos);
+#else
+      // as an extension v3 allows s[s.size()] when s is non-const.
+      _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
+                           _M_message(::__gnu_debug::__msg_subscript_oob)
+                           ._M_sequence(*this, "this")
+                           ._M_integer(__pos, "__pos")
+                           ._M_integer(this->size(), "size"));
+#endif
       return _M_base()[__pos];
     }
 
@@ -996,6 +1006,13 @@ namespace __gnu_debug
       __str._M_invalidate_all();
       return __res;
     }
+
+  typedef basic_string<char>    string;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  typedef basic_string<wchar_t> wstring;
+#endif
+
 } // namespace __gnu_debug
 
 #endif
diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc
new file mode 100644 (file)
index 0000000..dd4073f
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.9 search_n
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::forward_iterator_wrapper;
+
+struct X { };
+
+struct Y { };
+
+bool
+operator==(const X&, const Y&)
+{ return true; }
+
+forward_iterator_wrapper<X>
+test1(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end, int i, Y& value)
+{ return std::search_n(begin, end, i , value); }
index 435bb1d26b581521766af21bdebd6e2f69c38e95..1a6a295ee975e2b963197f9091b08d1278d940a9 100644 (file)
@@ -1,7 +1,7 @@
 // -*- C++ -*-
 // Iterator Wrappers for the C++ library testsuite. 
 //
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 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
@@ -77,7 +77,7 @@ namespace __gnu_test
       {
        writtento = new bool[this->last - this->first];
        for(int i = 0; i < this->last - this->first; i++)
-         writtento = false;
+         writtento[i] = false;
       }
 
       ~OutputContainer()
@@ -96,12 +96,13 @@ namespace __gnu_test
        ptr(ptr_in), SharedInfo(SharedInfo_in)
       { }
 
+      template<class U>
       void
-      operator=(T& new_val)
+      operator=(const U& new_val)
       {
        ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0);
        SharedInfo->writtento[ptr - SharedInfo->first] = 1;
-       ptr = new_val;
+       *ptr = new_val;
       }
     };
 
@@ -149,9 +150,9 @@ namespace __gnu_test
     operator++()
     {
       ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
-      ITERATOR_VERIFY(ptr>=SharedInfo->first);
+      ITERATOR_VERIFY(ptr>=SharedInfo->incrementedto);
       ptr++;
-      SharedInfo->first=ptr;
+      SharedInfo->incrementedto=ptr;
       return *this;
     }
 
@@ -423,7 +424,7 @@ namespace __gnu_test
     operator--(int)
     {
       random_access_iterator_wrapper<T> tmp = *this;
-      ++*this;
+      --*this;
       return tmp;
     }
 
@@ -443,34 +444,27 @@ namespace __gnu_test
       return *this;
     }
 
-    random_access_iterator_wrapper
-    operator+(ptrdiff_t n)
-    {
-      random_access_iterator_wrapper<T> tmp = *this;
-      return tmp += n;
-    }
-
     random_access_iterator_wrapper&
     operator-=(ptrdiff_t n)
     { return *this += -n; }
 
     random_access_iterator_wrapper
-    operator-(ptrdiff_t n)
+    operator-(ptrdiff_t n) const
     {
       random_access_iterator_wrapper<T> tmp = *this;
       return tmp -= n;
     }
 
     ptrdiff_t
-    operator-(const random_access_iterator_wrapper<T>& in)
+    operator-(const random_access_iterator_wrapper<T>& in) const
     {
       ITERATOR_VERIFY(this->SharedInfo == in.SharedInfo);
       return this->ptr - in.ptr;
     }
 
     T&
-    operator[](ptrdiff_t n)
-    { return *(this + n); }
+    operator[](ptrdiff_t n) const
+    { return *(*this + n); }
 
     bool
     operator<(const random_access_iterator_wrapper<T>& in) const
@@ -498,6 +492,16 @@ namespace __gnu_test
     }
    };
 
+  template<typename T>
+    random_access_iterator_wrapper<T>
+    operator+(random_access_iterator_wrapper<T> it, ptrdiff_t n)
+    { return it += n; }
+
+  template<typename T>
+    random_access_iterator_wrapper<T>
+    operator+(ptrdiff_t n, random_access_iterator_wrapper<T> it) 
+    { return it += n; }
+
 
   /** 
    * @brief A container-type class for holding iterator wrappers