From bbeb3976240dcd5237e4fc0eadbd66f9c79704f0 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 25 Jan 2024 15:14:49 +0100 Subject: [PATCH] STYLE: Add `const` to `pos` (iterator) variables in SpatialObject Following C++ Core Guidelines, October 12, 2023, "Always initialize an object" http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es20-always-initialize-an-object --- Modules/Core/SpatialObjects/include/itkSpatialObject.hxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx index 397fc445562..a9845a41c1d 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx @@ -410,8 +410,7 @@ template void SpatialObject::AddChild(Self * pointer) { - typename ChildrenListType::iterator pos; - pos = std::find(m_ChildrenList.begin(), m_ChildrenList.end(), pointer); + const typename ChildrenListType::iterator pos = std::find(m_ChildrenList.begin(), m_ChildrenList.end(), pointer); if (pos == m_ChildrenList.end()) { m_ChildrenList.push_back(pointer); @@ -431,8 +430,7 @@ template bool SpatialObject::RemoveChild(Self * pointer) { - typename ChildrenListType::iterator pos; - pos = std::find(m_ChildrenList.begin(), m_ChildrenList.end(), pointer); + const typename ChildrenListType::iterator pos = std::find(m_ChildrenList.begin(), m_ChildrenList.end(), pointer); if (pos != m_ChildrenList.end()) { m_ChildrenList.erase(pos);