summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-24 10:58:22 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-24 10:58:22 +0000
commitf71acafd7b5eabdf88dd59b241b14b51939c98ce (patch)
tree0175cad2a36b98bce2a07e455d894b5cfd122bff /libstdc++-v3
parentd277653476e10da74fc9b1d892fcf1c48f8f61c2 (diff)
downloadgcc-f71acafd7b5eabdf88dd59b241b14b51939c98ce.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100101 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog40
-rw-r--r--libstdc++-v3/include/bits/stl_algo.h10
-rw-r--r--libstdc++-v3/include/debug/string21
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc39
-rw-r--r--libstdc++-v3/testsuite/testsuite_iterators.h40
5 files changed, 124 insertions, 26 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bba5f417cfd..e39d577d540 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 7647ba342f8..469773cb3fe 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -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)
diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string
index a91c004e937..3893cd2b5f6 100644
--- a/libstdc++-v3/include/debug/string
+++ b/libstdc++-v3/include/debug/string
@@ -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
index 00000000000..dd4073ff308
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc
@@ -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); }
diff --git a/libstdc++-v3/testsuite/testsuite_iterators.h b/libstdc++-v3/testsuite/testsuite_iterators.h
index 435bb1d26b5..1a6a295ee97 100644
--- a/libstdc++-v3/testsuite/testsuite_iterators.h
+++ b/libstdc++-v3/testsuite/testsuite_iterators.h
@@ -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