insert_iterator.cc (test02): Add.
2001-12-26 Benjamin Kosnik <bkoz@waller.constant.com> * testsuite/24_iterators/insert_iterator.cc (test02): Add. * testsuite/24_iterators/front_insert_iterator.cc (test02): Add. * testsuite/24_iterators/back_insert_iterator.cc (test02): Add. * testsuite/24_iterators/reverse_iterator.cc (test02): Add. * include/bits/stl_iterator.h (reverse_iterator): Uglify member current to _M_current. (back_insert_iterator): Ulify member container to _M_container. (front_insert_iterator): Same. (insert_iterator): Same. From-SVN: r48318
This commit is contained in:
parent
7d8e83691e
commit
f591eb23d1
@ -1,3 +1,16 @@
|
||||
2001-12-26 Benjamin Kosnik <bkoz@waller.constant.com>
|
||||
|
||||
* testsuite/24_iterators/insert_iterator.cc (test02): Add.
|
||||
* testsuite/24_iterators/front_insert_iterator.cc (test02): Add.
|
||||
* testsuite/24_iterators/back_insert_iterator.cc (test02): Add.
|
||||
* testsuite/24_iterators/reverse_iterator.cc (test02): Add.
|
||||
|
||||
* include/bits/stl_iterator.h (reverse_iterator): Uglify member
|
||||
current to _M_current.
|
||||
(back_insert_iterator): Ulify member container to _M_container.
|
||||
(front_insert_iterator): Same.
|
||||
(insert_iterator): Same.
|
||||
|
||||
2001-12-25 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
|
||||
|
||||
* include/bits/std_limits.h (__glibcpp_xxx_is_modulo): New
|
||||
@ -5,7 +18,7 @@
|
||||
(numeric_limits<>::is_modulo): Get value from corresponding
|
||||
__glibcpp_xxx_is_modulo macro.
|
||||
|
||||
Sun Dec 23 18:47:24 2001 Jeffrey A Law (law@redhat.com)
|
||||
2001-12-23 Jeffrey A Law <law@redhat.com>
|
||||
|
||||
* config/os/hpux/bits/os_defines.h: Do not include <_sys/inttypes.h>.
|
||||
Twiddle return types for strtoll and strtoull to avoid using
|
||||
@ -15,13 +28,13 @@ Sun Dec 23 18:47:24 2001 Jeffrey A Law (law@redhat.com)
|
||||
|
||||
* configure.target (CPULIMITSH): Fix typo in alpha case.
|
||||
|
||||
Sat Dec 22 09:52:41 2001 Jeffrey A Law (law@redhat.com)
|
||||
2001-12-22 Jeffrey A Law <law@redhat.com>
|
||||
|
||||
* config/os/hpux/bits/os_defines.h: Update to avoid #defines
|
||||
* config/os/hpux/bits/os_defines.h: Update to avoid #defines
|
||||
for strtoll and strtoull.
|
||||
|
||||
Fri Dec 21 17:35:21 2001 Jeffrey A Law (law@redhat.com)
|
||||
|
||||
2001-12-21 Jeffrey A Law <law@redhat.com>
|
||||
|
||||
* config/os/hpux/bits/os_defines.h: Include <sys/_inttypes.h.
|
||||
Define strtoll and strtoull. Provide prototypes for
|
||||
__strtoll and __strtoull. Define _GLIBCPP_USE_LONG_LONG
|
||||
|
@ -66,14 +66,14 @@ namespace std
|
||||
// 24.4.1 Reverse iterators
|
||||
template<typename _Iterator>
|
||||
class reverse_iterator
|
||||
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
||||
typename iterator_traits<_Iterator>::value_type,
|
||||
typename iterator_traits<_Iterator>::difference_type,
|
||||
typename iterator_traits<_Iterator>::pointer,
|
||||
typename iterator_traits<_Iterator>::reference>
|
||||
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
||||
typename iterator_traits<_Iterator>::value_type,
|
||||
typename iterator_traits<_Iterator>::difference_type,
|
||||
typename iterator_traits<_Iterator>::pointer,
|
||||
typename iterator_traits<_Iterator>::reference>
|
||||
{
|
||||
protected:
|
||||
_Iterator current;
|
||||
_Iterator _M_current;
|
||||
|
||||
public:
|
||||
typedef _Iterator iterator_type;
|
||||
@ -83,25 +83,25 @@ namespace std
|
||||
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
||||
|
||||
public:
|
||||
reverse_iterator() {}
|
||||
reverse_iterator() { }
|
||||
|
||||
explicit
|
||||
reverse_iterator(iterator_type __x) : current(__x) {}
|
||||
reverse_iterator(iterator_type __x) : _M_current(__x) { }
|
||||
|
||||
reverse_iterator(const reverse_iterator& __x)
|
||||
: current(__x.current) { }
|
||||
: _M_current(__x._M_current) { }
|
||||
|
||||
template<typename _Iter>
|
||||
reverse_iterator(const reverse_iterator<_Iter>& __x)
|
||||
: current(__x.base()) {}
|
||||
: _M_current(__x.base()) { }
|
||||
|
||||
iterator_type
|
||||
base() const { return current; }
|
||||
base() const { return _M_current; }
|
||||
|
||||
reference
|
||||
operator*() const
|
||||
{
|
||||
_Iterator __tmp = current;
|
||||
_Iterator __tmp = _M_current;
|
||||
return *--__tmp;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace std
|
||||
reverse_iterator&
|
||||
operator++()
|
||||
{
|
||||
--current;
|
||||
--_M_current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -119,38 +119,38 @@ namespace std
|
||||
operator++(int)
|
||||
{
|
||||
reverse_iterator __tmp = *this;
|
||||
--current;
|
||||
--_M_current;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
reverse_iterator&
|
||||
operator--()
|
||||
{
|
||||
++current;
|
||||
++_M_current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reverse_iterator operator--(int)
|
||||
{
|
||||
reverse_iterator __tmp = *this;
|
||||
++current;
|
||||
++_M_current;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
reverse_iterator
|
||||
operator+(difference_type __n) const
|
||||
{ return reverse_iterator(current - __n); }
|
||||
{ return reverse_iterator(_M_current - __n); }
|
||||
|
||||
reverse_iterator&
|
||||
operator+=(difference_type __n)
|
||||
{
|
||||
current -= __n;
|
||||
_M_current -= __n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reverse_iterator
|
||||
operator-(difference_type __n) const
|
||||
{ return reverse_iterator(current + __n); }
|
||||
{ return reverse_iterator(_M_current + __n); }
|
||||
|
||||
reverse_iterator&
|
||||
operator-=(difference_type __n)
|
||||
@ -213,22 +213,22 @@ namespace std
|
||||
|
||||
// 24.4.2.2.1 back_insert_iterator
|
||||
template<typename _Container>
|
||||
class back_insert_iterator
|
||||
class back_insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
_Container* _M_container;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
|
||||
explicit
|
||||
back_insert_iterator(_Container& __x) : container(&__x) {}
|
||||
back_insert_iterator(_Container& __x) : _M_container(&__x) { }
|
||||
|
||||
back_insert_iterator&
|
||||
operator=(typename _Container::const_reference __value)
|
||||
{
|
||||
container->push_back(__value);
|
||||
_M_container->push_back(__value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -249,20 +249,20 @@ namespace std
|
||||
|
||||
template<typename _Container>
|
||||
class front_insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
_Container* _M_container;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
|
||||
explicit front_insert_iterator(_Container& __x) : container(&__x) {}
|
||||
explicit front_insert_iterator(_Container& __x) : _M_container(&__x) { }
|
||||
|
||||
front_insert_iterator&
|
||||
operator=(typename _Container::const_reference __value)
|
||||
{
|
||||
container->push_front(__value);
|
||||
_M_container->push_front(__value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -277,27 +277,28 @@ namespace std
|
||||
};
|
||||
|
||||
template<typename _Container>
|
||||
inline front_insert_iterator<_Container> front_inserter(_Container& __x)
|
||||
{ return front_insert_iterator<_Container>(__x); }
|
||||
inline front_insert_iterator<_Container>
|
||||
front_inserter(_Container& __x)
|
||||
{ return front_insert_iterator<_Container>(__x); }
|
||||
|
||||
template<typename _Container>
|
||||
class insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
_Container* _M_container;
|
||||
typename _Container::iterator iter;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
|
||||
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
||||
: container(&__x), iter(__i) {}
|
||||
: _M_container(&__x), iter(__i) {}
|
||||
|
||||
insert_iterator&
|
||||
operator=(const typename _Container::const_reference __value)
|
||||
{
|
||||
iter = container->insert(iter, __value);
|
||||
iter = _M_container->insert(iter, __value);
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
@ -313,11 +314,11 @@ namespace std
|
||||
};
|
||||
|
||||
template<typename _Container, typename _Iterator>
|
||||
inline
|
||||
insert_iterator<_Container> inserter(_Container& __x, _Iterator __i)
|
||||
inline insert_iterator<_Container>
|
||||
inserter(_Container& __x, _Iterator __i)
|
||||
{
|
||||
typedef typename _Container::iterator __iter;
|
||||
return insert_iterator<_Container>(__x, __iter(__i));
|
||||
return insert_iterator<_Container>(__x,
|
||||
typename _Container::iterator(__i));
|
||||
}
|
||||
|
||||
// This iterator adapter is 'normal' in the sense that it does not
|
||||
|
@ -43,8 +43,20 @@ void test01()
|
||||
typedef test_iterator::container_type container_type;
|
||||
}
|
||||
|
||||
|
||||
// Make sure iterator can be instantiated.
|
||||
template class std::back_insert_iterator<std::list<int> >;
|
||||
|
||||
void test02()
|
||||
{
|
||||
typedef std::back_insert_iterator<std::list<int> > iterator_type;
|
||||
std::list<int> li;
|
||||
iterator_type it = std::back_inserter(li);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,8 +43,19 @@ void test01()
|
||||
typedef test_iterator::container_type container_type;
|
||||
}
|
||||
|
||||
// Make sure iterator can be instantiated.
|
||||
template class std::front_insert_iterator<std::list<int> >;
|
||||
|
||||
void test02()
|
||||
{
|
||||
typedef std::front_insert_iterator<std::list<int> > iterator_type;
|
||||
std::list<int> li;
|
||||
iterator_type it = std::front_inserter(li);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
return 0;
|
||||
}
|
||||
|
@ -45,8 +45,24 @@ void test01()
|
||||
typedef test_iterator::container_type container_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Make sure iterator can be instantiated.
|
||||
template class std::insert_iterator<std::list<int> >;
|
||||
|
||||
void test02()
|
||||
{
|
||||
typedef std::insert_iterator<std::list<int> > iterator_type;
|
||||
|
||||
std::list<int> li;
|
||||
std::list<int>::iterator liit;
|
||||
iterator_type it01(li, liit);
|
||||
iterator_type it02 = std::inserter(li, liit);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,8 +46,33 @@ void test01()
|
||||
typedef test_iterator::iterator_category iteratory_category;
|
||||
}
|
||||
|
||||
|
||||
// Make sure iterator can be instantiated.
|
||||
template class std::reverse_iterator<int*>;
|
||||
|
||||
void test02()
|
||||
{
|
||||
typedef std::reverse_iterator<int*> iterator_type;
|
||||
iterator_type it01;
|
||||
iterator_type it02;
|
||||
|
||||
// Sanity check non-member operators and functions can be instantiated.
|
||||
it01 == it02;
|
||||
it01 != it02;
|
||||
it01 < it02;
|
||||
it01 <= it02;
|
||||
it01 > it02;
|
||||
it01 >= it02;
|
||||
it01 - it02;
|
||||
5 + it02;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user