]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add conversion operator to IteratorRange::IteratorOverIterators
authorJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 2 May 2019 17:31:10 +0000 (19:31 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 2 May 2019 17:31:10 +0000 (19:31 +0200)
include/deal.II/base/iterator_range.h

index ed39ffd6d9020006e91248e9f5558163e30c3f86..d2b054cb78cec2189693b1671e154ef6e9d81ff5 100644 (file)
@@ -174,6 +174,21 @@ public:
     bool
     operator!=(const IteratorOverIterators &i_o_i) const;
 
+    /**
+     * Implicit conversion operator.
+     *
+     * @warning When you call this conversion operator (i.e., you convert this
+     * iterator-over-iterators to the iterator we are currently pointing to),
+     * you obtain a `const` reference to this underlying iterator. The only
+     * thing you can really do with this result is dereferencing itself: it
+     * presumably points to something useful, but since you don't know where
+     * the pointed to object lives, you shouldn't increment or decrement the
+     * iterator you get from this operator. As a consequence, the returned
+     * iterator is marked as `const`, as this should prevent you from doing
+     * anything other than dereference it.
+     */
+    operator const BaseIterator &() const;
+
     /**
      * Mark the class as forward iterator and declare some alias which are
      * standard for iterators and are used by algorithms to enquire about the
@@ -297,6 +312,16 @@ operator!=(const IteratorOverIterators &i_o_i) const
 }
 
 
+
+template <typename Iterator>
+inline IteratorRange<Iterator>::IteratorOverIterators::
+operator const BaseIterator &() const
+{
+  return element_of_iterator_collection;
+}
+
+
+
 template <typename Iterator>
 inline IteratorRange<Iterator>::IteratorRange()
   : it_begin()

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.