#1042 GridView: support for C++11 range-based for statement
Metadata
Property | Value |
---|---|
Reported by | Ansgar Burchardt (burchardt@igpm.rwth-aachen.de) |
Reported at | Feb 17, 2012 10:27 |
Type | Feature Request |
Version | Git (pre2.4) [autotools] |
Operating System | Unspecified / All |
Last edited by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Last edited at | Sep 29, 2014 14:42 |
Closed by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Closed at | Sep 29, 2014 14:42 |
Closed in version | 2.4 |
Resolution | Implemented |
Comment | We now have support for iteration using range-based for! |
The relevant branches have been merged in: | |
core/dune-common@1a902a1e | |
core/dune-geometry@a90b6055 | |
core/dune-grid@9288b2c7 |
Description
It would be nice if the GridView interface would allow to use the new range-based for statement from C++11 to iterate over entities or intersections. This is currently not possible as it cannot get iterators via begin() and end() methods.
By adding new methods to the GridView interface that return an object providing begin() and end() methods wrapping gridview.template begin() resp. gridview.ibegin(entity), one could use the range-based for statement:
for (const auto &e : gv.entities<0>()) {
// do something
}
or
for (const auto &intersection : gv.intersections(entity)) {
// do something
}
I have attached a simple patch to implement this. (Please do not apply it yet, I would like to add some documentation before.)
Ansgar