rleap-project/dlplan

Public ABI: returning const ref

Closed this issue · 1 comments

I think that this was mentioned in the beginning by Guillem

In many cases, we return const reference from public ABI, e.g., e.g., const Atom& add_atom.
The user can then work with an invalid object if the object that stores it goes out of scope.
We might want to fix this and store/return the objects as shared_ptr or value.

This is not necessarily a design problem. One just has to document who owns what. Using shared_ptr for everything sounds appealing, but can make it harder to reason about ownership (see also http://modernescpp.com/index.php/component/jaggyblog/c-core-guidelines-rules-to-resource-management).