Change GridFactory::createGrid return type to unique_ptr for dune 2.7
About two years ago it was decided to change the interface of GridFactory
to return a unique_ptr
instead of a raw pointer. In order to allow a smooth transition to the new interface the idea was to add a helper class ToUniquePtr
that is essentially a unique pointer, but provides a cast to raw pointer including a deprecation warning.
This strategy had the advantage to allow older user-code to migrate to the new interface, since they just have to respect the warning and change their consumer type.
On the other hand, this strategy leads to preprocessor switches on the dune version in order to implement the interface version independent, i.e. one can find code like
template <>
class GridFactory<MyGridType> {
// ...
#if DUNE_VERSION_LT(DUNE_GRID,2,7)
MyGridType* createGrid() override { ... }
#else
ToUniquePtr<MyGridType> createGrid() override { ... }
#endif
};
in several external grid modules.
When it eventually comes to a full migration to unique_ptr
one has to add a third case in the implementation, for raw pointer (dune-grid <= 2.6), ToUniquePtr
(dune-grid 2.7), and unique_ptr
(dune-grid > 2.7).
Instead, I propose to change to unique_ptr
for the release dune-grid 2.7 already. There was a nearly 2 year transition time, so it should be fine. This means, the grid implementer has to handle only two different cases, just as now, but with unique_ptr
instead of ToUniquePtr
.
Any thoughts/opinion about this?