This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add symmetric operator+ to random_access_iterator_wrapper


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]