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>
|
2001-12-25 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
|
||||||
|
|
||||||
* include/bits/std_limits.h (__glibcpp_xxx_is_modulo): New
|
* include/bits/std_limits.h (__glibcpp_xxx_is_modulo): New
|
||||||
@ -5,7 +18,7 @@
|
|||||||
(numeric_limits<>::is_modulo): Get value from corresponding
|
(numeric_limits<>::is_modulo): Get value from corresponding
|
||||||
__glibcpp_xxx_is_modulo macro.
|
__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>.
|
* config/os/hpux/bits/os_defines.h: Do not include <_sys/inttypes.h>.
|
||||||
Twiddle return types for strtoll and strtoull to avoid using
|
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.
|
* 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.
|
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.
|
* config/os/hpux/bits/os_defines.h: Include <sys/_inttypes.h.
|
||||||
Define strtoll and strtoull. Provide prototypes for
|
Define strtoll and strtoull. Provide prototypes for
|
||||||
__strtoll and __strtoull. Define _GLIBCPP_USE_LONG_LONG
|
__strtoll and __strtoull. Define _GLIBCPP_USE_LONG_LONG
|
||||||
|
@ -66,14 +66,14 @@ namespace std
|
|||||||
// 24.4.1 Reverse iterators
|
// 24.4.1 Reverse iterators
|
||||||
template<typename _Iterator>
|
template<typename _Iterator>
|
||||||
class reverse_iterator
|
class reverse_iterator
|
||||||
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
||||||
typename iterator_traits<_Iterator>::value_type,
|
typename iterator_traits<_Iterator>::value_type,
|
||||||
typename iterator_traits<_Iterator>::difference_type,
|
typename iterator_traits<_Iterator>::difference_type,
|
||||||
typename iterator_traits<_Iterator>::pointer,
|
typename iterator_traits<_Iterator>::pointer,
|
||||||
typename iterator_traits<_Iterator>::reference>
|
typename iterator_traits<_Iterator>::reference>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
_Iterator current;
|
_Iterator _M_current;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Iterator iterator_type;
|
typedef _Iterator iterator_type;
|
||||||
@ -83,25 +83,25 @@ namespace std
|
|||||||
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
reverse_iterator() {}
|
reverse_iterator() { }
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
reverse_iterator(iterator_type __x) : current(__x) {}
|
reverse_iterator(iterator_type __x) : _M_current(__x) { }
|
||||||
|
|
||||||
reverse_iterator(const reverse_iterator& __x)
|
reverse_iterator(const reverse_iterator& __x)
|
||||||
: current(__x.current) { }
|
: _M_current(__x._M_current) { }
|
||||||
|
|
||||||
template<typename _Iter>
|
template<typename _Iter>
|
||||||
reverse_iterator(const reverse_iterator<_Iter>& __x)
|
reverse_iterator(const reverse_iterator<_Iter>& __x)
|
||||||
: current(__x.base()) {}
|
: _M_current(__x.base()) { }
|
||||||
|
|
||||||
iterator_type
|
iterator_type
|
||||||
base() const { return current; }
|
base() const { return _M_current; }
|
||||||
|
|
||||||
reference
|
reference
|
||||||
operator*() const
|
operator*() const
|
||||||
{
|
{
|
||||||
_Iterator __tmp = current;
|
_Iterator __tmp = _M_current;
|
||||||
return *--__tmp;
|
return *--__tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ namespace std
|
|||||||
reverse_iterator&
|
reverse_iterator&
|
||||||
operator++()
|
operator++()
|
||||||
{
|
{
|
||||||
--current;
|
--_M_current;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,38 +119,38 @@ namespace std
|
|||||||
operator++(int)
|
operator++(int)
|
||||||
{
|
{
|
||||||
reverse_iterator __tmp = *this;
|
reverse_iterator __tmp = *this;
|
||||||
--current;
|
--_M_current;
|
||||||
return __tmp;
|
return __tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator&
|
reverse_iterator&
|
||||||
operator--()
|
operator--()
|
||||||
{
|
{
|
||||||
++current;
|
++_M_current;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator operator--(int)
|
reverse_iterator operator--(int)
|
||||||
{
|
{
|
||||||
reverse_iterator __tmp = *this;
|
reverse_iterator __tmp = *this;
|
||||||
++current;
|
++_M_current;
|
||||||
return __tmp;
|
return __tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
operator+(difference_type __n) const
|
operator+(difference_type __n) const
|
||||||
{ return reverse_iterator(current - __n); }
|
{ return reverse_iterator(_M_current - __n); }
|
||||||
|
|
||||||
reverse_iterator&
|
reverse_iterator&
|
||||||
operator+=(difference_type __n)
|
operator+=(difference_type __n)
|
||||||
{
|
{
|
||||||
current -= __n;
|
_M_current -= __n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator
|
reverse_iterator
|
||||||
operator-(difference_type __n) const
|
operator-(difference_type __n) const
|
||||||
{ return reverse_iterator(current + __n); }
|
{ return reverse_iterator(_M_current + __n); }
|
||||||
|
|
||||||
reverse_iterator&
|
reverse_iterator&
|
||||||
operator-=(difference_type __n)
|
operator-=(difference_type __n)
|
||||||
@ -213,22 +213,22 @@ namespace std
|
|||||||
|
|
||||||
// 24.4.2.2.1 back_insert_iterator
|
// 24.4.2.2.1 back_insert_iterator
|
||||||
template<typename _Container>
|
template<typename _Container>
|
||||||
class back_insert_iterator
|
class back_insert_iterator
|
||||||
: public iterator<output_iterator_tag, void, void, void, void>
|
: public iterator<output_iterator_tag, void, void, void, void>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
_Container* container;
|
_Container* _M_container;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Container container_type;
|
typedef _Container container_type;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
back_insert_iterator(_Container& __x) : container(&__x) {}
|
back_insert_iterator(_Container& __x) : _M_container(&__x) { }
|
||||||
|
|
||||||
back_insert_iterator&
|
back_insert_iterator&
|
||||||
operator=(typename _Container::const_reference __value)
|
operator=(typename _Container::const_reference __value)
|
||||||
{
|
{
|
||||||
container->push_back(__value);
|
_M_container->push_back(__value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,20 +249,20 @@ namespace std
|
|||||||
|
|
||||||
template<typename _Container>
|
template<typename _Container>
|
||||||
class front_insert_iterator
|
class front_insert_iterator
|
||||||
: public iterator<output_iterator_tag, void, void, void, void>
|
: public iterator<output_iterator_tag, void, void, void, void>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
_Container* container;
|
_Container* _M_container;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Container container_type;
|
typedef _Container container_type;
|
||||||
|
|
||||||
explicit front_insert_iterator(_Container& __x) : container(&__x) {}
|
explicit front_insert_iterator(_Container& __x) : _M_container(&__x) { }
|
||||||
|
|
||||||
front_insert_iterator&
|
front_insert_iterator&
|
||||||
operator=(typename _Container::const_reference __value)
|
operator=(typename _Container::const_reference __value)
|
||||||
{
|
{
|
||||||
container->push_front(__value);
|
_M_container->push_front(__value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,27 +277,28 @@ namespace std
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Container>
|
template<typename _Container>
|
||||||
inline front_insert_iterator<_Container> front_inserter(_Container& __x)
|
inline front_insert_iterator<_Container>
|
||||||
{ return front_insert_iterator<_Container>(__x); }
|
front_inserter(_Container& __x)
|
||||||
|
{ return front_insert_iterator<_Container>(__x); }
|
||||||
|
|
||||||
template<typename _Container>
|
template<typename _Container>
|
||||||
class insert_iterator
|
class insert_iterator
|
||||||
: public iterator<output_iterator_tag, void, void, void, void>
|
: public iterator<output_iterator_tag, void, void, void, void>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
_Container* container;
|
_Container* _M_container;
|
||||||
typename _Container::iterator iter;
|
typename _Container::iterator iter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Container container_type;
|
typedef _Container container_type;
|
||||||
|
|
||||||
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
||||||
: container(&__x), iter(__i) {}
|
: _M_container(&__x), iter(__i) {}
|
||||||
|
|
||||||
insert_iterator&
|
insert_iterator&
|
||||||
operator=(const typename _Container::const_reference __value)
|
operator=(const typename _Container::const_reference __value)
|
||||||
{
|
{
|
||||||
iter = container->insert(iter, __value);
|
iter = _M_container->insert(iter, __value);
|
||||||
++iter;
|
++iter;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -313,11 +314,11 @@ namespace std
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename _Container, typename _Iterator>
|
template<typename _Container, typename _Iterator>
|
||||||
inline
|
inline insert_iterator<_Container>
|
||||||
insert_iterator<_Container> inserter(_Container& __x, _Iterator __i)
|
inserter(_Container& __x, _Iterator __i)
|
||||||
{
|
{
|
||||||
typedef typename _Container::iterator __iter;
|
return insert_iterator<_Container>(__x,
|
||||||
return insert_iterator<_Container>(__x, __iter(__i));
|
typename _Container::iterator(__i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This iterator adapter is 'normal' in the sense that it does not
|
// 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;
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,19 @@ void test01()
|
|||||||
typedef test_iterator::container_type container_type;
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,24 @@ void test01()
|
|||||||
typedef test_iterator::container_type container_type;
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,33 @@ void test01()
|
|||||||
typedef test_iterator::iterator_category iteratory_category;
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user