From: Matthias Maier Date: Thu, 28 Feb 2019 20:23:12 +0000 (-0600) Subject: SparsityPattern::Iterator - add a constructor for initalizing an iterator from an... X-Git-Tag: v9.1.0-rc1~313^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b541384f0210bbf8140d7442ede9039fee4a831;p=dealii.git SparsityPattern::Iterator - add a constructor for initalizing an iterator from an accessor When trying to increment a sparsity pattern iterator: auto iterator = sparsity_pattern.begin(); iterator++; The corresponding function in LinearIndexIterator: template inline DerivedIterator LinearIndexIterator::operator++(int) { const DerivedIterator copy(this->accessor); operator+=(1); return copy; } creates a copy that is initialized by the accessor. Thus, we need a constructor that can create an interator from an accessor. --- diff --git a/include/deal.II/lac/sparsity_pattern.h b/include/deal.II/lac/sparsity_pattern.h index 89c507a31e..573c6c2947 100644 --- a/include/deal.II/lac/sparsity_pattern.h +++ b/include/deal.II/lac/sparsity_pattern.h @@ -298,6 +298,12 @@ namespace SparsityPatternIterators * the zeroth row). */ Iterator(const SparsityPattern *sp, const std::size_t linear_index); + + /** + * Constructor. Create an iterator into the sparsity pattern @p sp for + * a given accessor. + */ + Iterator(const Accessor &accessor); }; } // namespace SparsityPatternIterators @@ -1272,6 +1278,13 @@ namespace SparsityPatternIterators const std::size_t linear_index) : LinearIndexIterator(Accessor(sp, linear_index)) {} + + + inline Iterator::Iterator(const Accessor &accessor) + : LinearIndexIterator(accessor) + {} + + } // namespace SparsityPatternIterators