From 561e7a36e38004d567ada2f0dac327b80d506009 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 24 May 2005 10:58:22 +0000 Subject: [PATCH] [multiple changes] 2005-05-24 Jonathan Wakely * 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 Port from libstdcxx_so_7-branch: 2005-04-25 Christopher Jefferson * 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 * testsuite/testsuite_iterators.h (WritableObject::WritableObject): Add const. 2005-02-01 Christopher Jefferson * 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 | 40 +++++++++++++++++++ libstdc++-v3/include/bits/stl_algo.h | 10 ++--- libstdc++-v3/include/debug/string | 21 +++++++++- .../25_algorithms/search_n/check_type.cc | 39 ++++++++++++++++++ libstdc++-v3/testsuite/testsuite_iterators.h | 40 ++++++++++--------- 5 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc 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 + + * 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 + + Port from libstdcxx_so_7-branch: + 2005-04-25 Christopher Jefferson + + * 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 + + * testsuite/testsuite_iterators.h (WritableObject::WritableObject): + Add const. + + 2005-02-01 Christopher Jefferson + + * 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 * 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 +template, + typename _Allocator = std::allocator<_CharT> > class basic_string : public std::basic_string<_CharT, _Traits, _Allocator>, public __gnu_debug::_Safe_sequencesize(), + _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 string; + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef basic_string 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 +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& 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 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 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 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 tmp = *this; return tmp -= n; } ptrdiff_t - operator-(const random_access_iterator_wrapper& in) + operator-(const random_access_iterator_wrapper& 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& in) const @@ -498,6 +492,16 @@ namespace __gnu_test } }; + template + random_access_iterator_wrapper + operator+(random_access_iterator_wrapper it, ptrdiff_t n) + { return it += n; } + + template + random_access_iterator_wrapper + operator+(ptrdiff_t n, random_access_iterator_wrapper it) + { return it += n; } + /** * @brief A container-type class for holding iterator wrappers -- 2.30.2