Skip to content

Fix lifetime issues for Face::halfedges(), Cell::halffaces().

Martin Heistermann requested to merge fix-lifetime-issue into master

Currently, the following API-usage is straight-forward and clean but unfortunately wrong and dangerous:

for (const auto heh: mesh.face(fh).halfedges()) { ... }

This is because the temporary Face returned by face() reaches the end of its lifetime, but halfedges() returned a reference to a vector that lives inside that object. Reference lifetime extension does not apply here.

This change splits behaviour so that in rvalue context (such as temporaries), we move out the vector instead of returning a reference to it.

Merge request reports