This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add symmetric operator+ to random_access_iterator_wrapper
- From: Christopher Jefferson <caj at cs dot york dot ac dot uk>
- To: Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Apr 2005 17:30:16 +0100
- Subject: Add symmetric operator+ to random_access_iterator_wrapper
- References: <20050418151844.GA69028@compsoc.man.ac.uk>
This patch adds missing overloads to operator+ of
random_access_iterator_wrapper. (Note: This doesn't fix all the errors
Jonathan reported, more patches to follow!)
Index: testsuite_iterators.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libstdc++-v3/testsuite/testsuite_iterators.h,v
retrieving revision 1.1.6.3
diff -u -r1.1.6.3 testsuite_iterators.h
--- testsuite_iterators.h 14 Mar 2005 10:38:04 -0000 1.1.6.3
+++ testsuite_iterators.h 19 Apr 2005 16:21:34 -0000
@@ -444,23 +444,10 @@
return *this;
}
- random_access_iterator_wrapper
- operator+(ptrdiff_t n) const
- {
- 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) const
- {
- random_access_iterator_wrapper<T> tmp = *this;
- return tmp -= n;
- }
ptrdiff_t
operator-(const random_access_iterator_wrapper<T>& in) const
@@ -499,6 +486,37 @@
}
};
+ template<typename T>
+ random_access_iterator_wrapper<T>
+ operator+(random_access_iterator_wrapper<T> it, ptrdiff_t n)
+ {
+ random_access_iterator_wrapper<T> tmp = it;
+ return tmp += n;
+ }
+
+ template<typename T>
+ random_access_iterator_wrapper<T>
+ operator+(ptrdiff_t n, random_access_iterator_wrapper<T> it)
+ {
+ random_access_iterator_wrapper<T> tmp = it;
+ return tmp += n;
+ }
+
+ template<typename T>
+ random_access_iterator_wrapper<T>
+ operator-(random_access_iterator_wrapper<T> it, ptrdiff_t n)
+ {
+ random_access_iterator_wrapper<T> tmp = it;
+ return tmp -= n;
+ }
+
+ template<typename T>
+ random_access_iterator_wrapper<T>
+ operator-(ptrdiff_t n, random_access_iterator_wrapper<T> it)
+ {
+ random_access_iterator_wrapper<T> tmp = it;
+ return tmp -= n;
+ }
/**
* @brief A container-type class for holding iterator wrappers
2005-04-19 Christopher Jefferson <chris@bubblescope.net>
* testsuite/testsuite_iterators.h
(random_access_iterator_wrapper::operator+) : Move out of inline
and add symmetric equivalent.
(random_access_iterator_wrapper::operator-) : Likewise.