Skip to content

Code modernization: unique_ptrs in objects owned by a Formulation

Boris Martin requested to merge unique_ptrs into master

Simplified memory management: for objects owned by a formulation (_solver, _A, _b), the C-style pointer is replaced by unique_ptr, which removes the need for manual deletion. When possible, some functions reading pointers were changed to use references instead. Otherwise, backwards compatibility is kept through unique_ptr::get().

A tricky case is the one concerning a Solver's pointers to _A and _b. Currently they use direct pointers, which makes ownership ambiguous. An option would to use shared/weak pointers. Otherwise we could also have the solver keep a reference to its "parent" formulation and ask directly for the formulation's A/b. But it could be less generic if at some point a Solver becomes less coupled to a Formulation.

Poke @geuzaine since you're interested in modern C++

Merge request reports