]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added operator* to SynchronousIterators
authordanshapero <shapero.daniel@gmail.com>
Thu, 23 Jun 2016 21:31:31 +0000 (14:31 -0700)
committerdanshapero <shapero.daniel@gmail.com>
Fri, 24 Jun 2016 22:11:18 +0000 (15:11 -0700)
include/deal.II/base/synchronous_iterator.h

index 05ec5a20942cce0c9cc082085f2fbcb519ac06d6..c0c9238d5924ce1ad0e7c0841b80153bc9146d28 100644 (file)
@@ -60,6 +60,18 @@ struct SynchronousIterators
    */
   SynchronousIterators (const SynchronousIterators &i);
 
+  /**
+   * Dereference const operator. Returns a const reference to the iterators
+   * represented by the current class.
+   */
+  const Iterators &operator* () const;
+
+  /**
+   * Dereference operator. Returns a reference to the iterators
+   * represented by the current class.
+   */
+  Iterators &operator* ();
+
   /**
    * Storage for the iterators represented by the current class.
    */
@@ -87,6 +99,26 @@ SynchronousIterators (const SynchronousIterators &i)
 
 
 
+template <typename Iterators>
+inline
+const Iterators &
+SynchronousIterators<Iterators>::operator* () const
+{
+  return iterators;
+}
+
+
+
+template <typename Iterators>
+inline
+Iterators &
+SynchronousIterators<Iterators>::operator* ()
+{
+  return iterators;
+}
+
+
+
 /**
  * Return whether the first element of the first argument is less than the
  * first element of the second argument. Since the objects compared march
@@ -101,7 +133,7 @@ bool
 operator< (const SynchronousIterators<Iterators> &a,
            const SynchronousIterators<Iterators> &b)
 {
-  return std_cxx11::get<0>(a.iterators) < std_cxx11::get<0>(b.iterators);
+  return std_cxx11::get<0>(*a) < std_cxx11::get<0>(*b);
 }
 
 
@@ -119,11 +151,11 @@ std::size_t
 operator- (const SynchronousIterators<Iterators> &a,
            const SynchronousIterators<Iterators> &b)
 {
-  Assert (std::distance (std_cxx11::get<0>(b.iterators),
-                         std_cxx11::get<0>(a.iterators)) >= 0,
+  Assert (std::distance (std_cxx11::get<0>(*b),
+                         std_cxx11::get<0>(*a)) >= 0,
           ExcInternalError());
-  return std::distance (std_cxx11::get<0>(b.iterators),
-                        std_cxx11::get<0>(a.iterators));
+  return std::distance (std_cxx11::get<0>(*b),
+                        std_cxx11::get<0>(*a));
 }
 
 
@@ -232,7 +264,7 @@ operator + (const SynchronousIterators<Iterators> &a,
             const std::size_t                      n)
 {
   SynchronousIterators<Iterators> x (a);
-  dealii::advance (x.iterators, n);
+  dealii::advance (*x, n);
   return x;
 }
 
@@ -246,7 +278,7 @@ inline
 SynchronousIterators<Iterators>
 operator ++ (SynchronousIterators<Iterators> &a)
 {
-  dealii::advance_by_one (a.iterators);
+  dealii::advance_by_one (*a);
   return a;
 }
 
@@ -263,8 +295,8 @@ bool
 operator != (const SynchronousIterators<Iterators> &a,
              const SynchronousIterators<Iterators> &b)
 {
-  return (std_cxx11::get<0>(a.iterators) !=
-          std_cxx11::get<0>(b.iterators));
+  return (std_cxx11::get<0>(*a) !=
+          std_cxx11::get<0>(*b));
 }
 
 DEAL_II_NAMESPACE_CLOSE

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.