COMP: Use std::unique_ptr in FEMLinearSystemWrapperDenseVNL#5995
Conversation
be010a1 to
7769a5c
Compare
|
| Filename | Overview |
|---|---|
| Modules/Numerics/FEM/include/itkFEMLinearSystemWrapperDenseVNL.h | Modernized member types from raw pointers to std::unique_ptr; added #include ; defaulted destructor. Minor style note: VectorHolder alias inconsistency. |
| Modules/Numerics/FEM/src/itkFEMLinearSystemWrapperDenseVNL.cxx | Replaced all new/delete with std::make_unique/reset, manual pointer swaps with std::swap, and removed the manual destructor body. All changes are semantically correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[LinearSystemWrapperDenseVNL] --> B["m_Matrices\nunique_ptr<MatrixHolder>"]
A --> C["m_Vectors\nunique_ptr<vector<unique_ptr<vnl_vector>>>"]
A --> D["m_Solutions\nunique_ptr<vector<unique_ptr<vnl_vector>>>"]
B --> B1["MatrixHolder\nvector<unique_ptr<vnl_matrix<Float>>>"]
B1 --> B2["unique_ptr<MatrixRepresentation> [0..N]"]
C --> C1["unique_ptr<vnl_vector<Float>> [0..N]"]
D --> D1["unique_ptr<vnl_vector<Float>> [0..N]"]
style A fill:#4a90d9,color:#fff
style B fill:#7ec8a0,color:#000
style C fill:#7ec8a0,color:#000
style D fill:#7ec8a0,color:#000
Reviews (1): Last reviewed commit: "COMP: Use std::unique_ptr in FEMLinearSy..." | Re-trigger Greptile
Replace raw pointer members and new/delete with std::unique_ptr and std::make_unique. Use std::swap for all Swap* methods. Destructor is defaulted since unique_ptr handles cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7769a5c to
b5f92fb
Compare
N-Dekker
left a comment
There was a problem hiding this comment.
Thanks Hans! Almost perfect. 😇 Just one change request: Please move VectorHolder to the private section of the class.
|
This PR is clearly an improvement. However, I wonder if the extra pointer indirection is really necessary! Why not simply using |
That change should be investigated and performed as a separate PR that builds upon this PR. It is a change outside the scope of what was being worked on here. |
VectorHolder is only used internally by m_Vectors and m_Solutions members, so it should not be part of the public API. Addresses review comment from @N-Dekker on PR InsightSoftwareConsortium#5995. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These type aliases are only used internally by private member variables and implementation details. Moving them to private keeps the public API minimal and consistent with the VectorHolder change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Addressed @N-Dekker's review: moved |
|
@N-Dekker I had a change of heart. In the pursuit to make this perfect, I want to keep the entire conversation together. When moving the VectorHolder (new alias) to private, it raised the question about MatrixRepresentation and MatrixHolder (ITKv5 public API aliases). I had a migration guide entry generated and moved those two items to private as well. I would guess that those were not intended to be part of the public interface. |
|
Thanks Hans, I agree with this change: making MatrixRepresentation and MatrixHolder private. Note that the "official way" would be to deprecate and future-legacy-remove them. But these two typedefs were clearly never meant to be part of the API. |
My change request to make VectorHolder private is addressed
Document the removal of MatrixRepresentation and MatrixHolder type aliases from the public interface of LinearSystemWrapperDenseVNL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4ab00d8 to
7d94b93
Compare
19eb086
into
InsightSoftwareConsortium:main
Summary
Replace raw
new/deleteof matrix and vector holders inFEMLinearSystemWrapperDenseVNLwithstd::unique_ptrandstd::make_unique, following C++ Core Guidelines R.11 and R.20.new/deleteofvnl_matrixandvnl_vectorholder objects withstd::unique_ptrandstd::make_uniquestd::swapfor all swap methods instead of manual pointer shufflingdeleteneeded)Test plan
ctest -R FEM)🤖 Generated with Claude Code