-
- Downloads
[referenceelements] Warn users when they capture reference elements by reference
This patch adds partial support for warning users about capturing reference elements by const ref. Capturing objects with value semantics by const ref is fine as long as the captured value is not used outside of the current scope, which can happen e.g. when assigning to a class member in a constructor. We've had quite a few problems with this when moving the geometries and entities to value semantics, so this patch tries to warn as best as it can in this situation. It works as long as the user is still explicity using the type `const Dune::ReferenceElement<ctype,dim>&` for capturing the reference. Internally, it works by making the type pointed to by the type alias `Dune::ReferenceElement` a child of the type returned by the container and providing a deprecated conversion operator to the derived reference type. The code also makes sure that this still works in case the value-based reference element returned by the container has been copied around before by always returning a reference to the prototype reference element in the container. This should catch most usages. The user is only out of lucks out if they already changed to capturing by `auto&`, but in that case, there's nothing we can do.
parent
887de873
No related branches found
No related tags found
Please register or sign in to comment