From f875a0474a65ca741543eb3af052ff98a9e33133 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Thu, 2 May 2019 19:31:10 +0200 Subject: [PATCH] Add conversion operator to IteratorRange::IteratorOverIterators --- include/deal.II/base/iterator_range.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/deal.II/base/iterator_range.h b/include/deal.II/base/iterator_range.h index ed39ffd6d9..d2b054cb78 100644 --- a/include/deal.II/base/iterator_range.h +++ b/include/deal.II/base/iterator_range.h @@ -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 +inline IteratorRange::IteratorOverIterators:: +operator const BaseIterator &() const +{ + return element_of_iterator_collection; +} + + + template inline IteratorRange::IteratorRange() : it_begin() -- 2.39.5