Pass grid ownership with unique_ptr for clarity.
Grid creation methods hand over the ownership.
The returned grids are no longer passed as pure pointers (Grid*
) but with dynamic memory management features (std::unique_ptr<Grid>
).
Users of these methods might have to change their code to account for the following issues at least:
- The return values cannot be cast to
Grid*
type. You should useget()
for that or, better, take ownership with astd::unique_ptr<Grid>
. - Explicit
delete
s conflict with the dynamic memory management (and can most likely just be scrapped in favor of theunique_ptr
eventually going out of scope).
Note: The make***.hh
-classes still exhibit several grid construction methods that cannot be used with arbitrary grid factories (because they call a constructor that is not required by the grid factory interface), despite lacking a proper reason for such a restriction.