HierarchicIterator not properly copyable if end reached through increment
Hi,
I encountered the following bug (at least I consider it one): An hierarchic iterator incremented till the end does not behave the same as an hierarchic iterator given by method hend directly. Copy construction fails on the supposedly false last increment result of the hierarchic iterator.
I work with:
- dune-alugrid sha1 (most recent master): 8c97bf5d
- dune-grid sha1 (releases/2.4): 314870a4c017 (and an unrelated private commit)
I created a MWE here:
using Grid = Dune::ALUGrid<2, 2, Dune::ALUGridElementType::simplex, Dune::ALUGridRefinementType::nonconforming>;
Dune::GridFactory<Grid> factory;
Dune::GeometryType dSimplex(Dune::GeometryType::simplex, 2);
factory.insertVertex({0, 0});
factory.insertVertex({1, 0});
factory.insertVertex({1, 1});
factory.insertVertex({0, 1});
factory.insertElement(dSimplex, {0, 1, 2});
factory.insertElement(dSimplex, {0, 2, 3});
auto* grid = factory.createGrid();
grid->globalRefine(1);
using HierarchicIterator = typename Grid::HierarchicIterator;
auto end = grid->levelView(0).template begin<0>()->hend(1);
HierarchicIterator end_copy(end); // works
auto begin = grid->levelView(0).template begin<0>()->hbegin(1);
while(begin != end) ++begin;
HierarchicIterator end_from_begin_copy(begin); // doesn't work
I investigated this with a debugger. I assume, that the issue arises because the member seed_ gets cleared for both cases, but the iterated object still holds some entity_ which leads to the assertion failure.