Skip to content

Make file readers return ToUniquePtr instead of a C pointer

Oliver Sander requested to merge feature/grid-readers-return-to_unique_ptr into master

At the 2017 developer meeting in Heidelberg it was decided that file reading methods should return a std::unique_ptr of the resulting grid, rather than a C pointer. The reason is that a std::unique_ptr makes it clear that the caller receives the ownership of the new object.

Simply changing the return types of the relevant methods is not an option, as it will break a lot of user code. Instead the class ToUniquePtr was introduced in dune-common. It is a costum pointer class that casts into C-style pointers, std::shared_ptr, and std::unique_ptr. Casting to a C-style pointer will result in a deprecation warning. Using this class for at least one release will allow a much smoother transition.

Merge request reports