Commit 561e7a36 by Paolo Carlini

[multiple changes]

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
parent 89f9fe50
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> 2005-05-23 Jonathan Wakely <redi@gcc.gnu.org>
* docs/html/debug.html: Explain that _GLIBXX_DEBUG_PEDANTIC * docs/html/debug.html: Explain that _GLIBXX_DEBUG_PEDANTIC
......
...@@ -413,9 +413,8 @@ namespace std ...@@ -413,9 +413,8 @@ namespace std
{ {
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_EqualityComparableConcept< __glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_InputIterator>::value_type >) typename iterator_traits<_InputIterator>::value_type, _Tp>)
__glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
typename iterator_traits<_InputIterator>::difference_type __n = 0; typename iterator_traits<_InputIterator>::difference_type __n = 0;
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
...@@ -627,9 +626,8 @@ namespace std ...@@ -627,9 +626,8 @@ namespace std
{ {
// concept requirements // concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_EqualityComparableConcept< __glibcxx_function_requires(_EqualOpConcept<
typename iterator_traits<_ForwardIterator>::value_type>) typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
__glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
if (__count <= 0) if (__count <= 0)
......
// Debugging string implementation -*- C++ -*- // Debugging string implementation -*- C++ -*-
// Copyright (C) 2003 // Copyright (C) 2003, 2005
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
namespace __gnu_debug 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 class basic_string
: public std::basic_string<_CharT, _Traits, _Allocator>, : public std::basic_string<_CharT, _Traits, _Allocator>,
public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits, public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
...@@ -213,7 +214,16 @@ namespace __gnu_debug ...@@ -213,7 +214,16 @@ namespace __gnu_debug
reference reference
operator[](size_type __pos) operator[](size_type __pos)
{ {
#ifdef _GLIBCXX_DEBUG_PEDANTIC
__glibcxx_check_subscript(__pos); __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]; return _M_base()[__pos];
} }
...@@ -996,6 +1006,13 @@ namespace __gnu_debug ...@@ -996,6 +1006,13 @@ namespace __gnu_debug
__str._M_invalidate_all(); __str._M_invalidate_all();
return __res; return __res;
} }
typedef basic_string<char> string;
#ifdef _GLIBCXX_USE_WCHAR_T
typedef basic_string<wchar_t> wstring;
#endif
} // namespace __gnu_debug } // namespace __gnu_debug
#endif #endif
// 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); }
// -*- C++ -*- // -*- C++ -*-
// Iterator Wrappers for the C++ library testsuite. // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -77,7 +77,7 @@ namespace __gnu_test ...@@ -77,7 +77,7 @@ namespace __gnu_test
{ {
writtento = new bool[this->last - this->first]; writtento = new bool[this->last - this->first];
for(int i = 0; i < this->last - this->first; i++) for(int i = 0; i < this->last - this->first; i++)
writtento = false; writtento[i] = false;
} }
~OutputContainer() ~OutputContainer()
...@@ -96,12 +96,13 @@ namespace __gnu_test ...@@ -96,12 +96,13 @@ namespace __gnu_test
ptr(ptr_in), SharedInfo(SharedInfo_in) ptr(ptr_in), SharedInfo(SharedInfo_in)
{ } { }
template<class U>
void void
operator=(T& new_val) operator=(const U& new_val)
{ {
ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0); ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0);
SharedInfo->writtento[ptr - SharedInfo->first] = 1; SharedInfo->writtento[ptr - SharedInfo->first] = 1;
ptr = new_val; *ptr = new_val;
} }
}; };
...@@ -149,9 +150,9 @@ namespace __gnu_test ...@@ -149,9 +150,9 @@ namespace __gnu_test
operator++() operator++()
{ {
ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last); ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
ITERATOR_VERIFY(ptr>=SharedInfo->first); ITERATOR_VERIFY(ptr>=SharedInfo->incrementedto);
ptr++; ptr++;
SharedInfo->first=ptr; SharedInfo->incrementedto=ptr;
return *this; return *this;
} }
...@@ -423,7 +424,7 @@ namespace __gnu_test ...@@ -423,7 +424,7 @@ namespace __gnu_test
operator--(int) operator--(int)
{ {
random_access_iterator_wrapper<T> tmp = *this; random_access_iterator_wrapper<T> tmp = *this;
++*this; --*this;
return tmp; return tmp;
} }
...@@ -443,34 +444,27 @@ namespace __gnu_test ...@@ -443,34 +444,27 @@ namespace __gnu_test
return *this; return *this;
} }
random_access_iterator_wrapper
operator+(ptrdiff_t n)
{
random_access_iterator_wrapper<T> tmp = *this;
return tmp += n;
}
random_access_iterator_wrapper& random_access_iterator_wrapper&
operator-=(ptrdiff_t n) operator-=(ptrdiff_t n)
{ return *this += -n; } { return *this += -n; }
random_access_iterator_wrapper random_access_iterator_wrapper
operator-(ptrdiff_t n) operator-(ptrdiff_t n) const
{ {
random_access_iterator_wrapper<T> tmp = *this; random_access_iterator_wrapper<T> tmp = *this;
return tmp -= n; return tmp -= n;
} }
ptrdiff_t 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); ITERATOR_VERIFY(this->SharedInfo == in.SharedInfo);
return this->ptr - in.ptr; return this->ptr - in.ptr;
} }
T& T&
operator[](ptrdiff_t n) operator[](ptrdiff_t n) const
{ return *(this + n); } { return *(*this + n); }
bool bool
operator<(const random_access_iterator_wrapper<T>& in) const operator<(const random_access_iterator_wrapper<T>& in) const
...@@ -498,6 +492,16 @@ namespace __gnu_test ...@@ -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 * @brief A container-type class for holding iterator wrappers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment