From: Jean-Paul Pelteret Date: Thu, 2 May 2019 17:31:10 +0000 (+0200) Subject: Add conversion operator to IteratorRange::IteratorOverIterators X-Git-Tag: v9.1.0-rc1~126^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f875a0474a65ca741543eb3af052ff98a9e33133;p=dealii.git Add conversion operator to IteratorRange::IteratorOverIterators --- 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()