Skip to content

Commit

Permalink
STYLE: Add const to pos (iterator) variables in SpatialObject
Browse files Browse the repository at this point in the history
Following C++ Core Guidelines, October 12, 2023, "Always initialize an object"
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es20-always-initialize-an-object
  • Loading branch information
N-Dekker committed Jan 25, 2024
1 parent f3e9b6d commit bbeb397
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Modules/Core/SpatialObjects/include/itkSpatialObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ template <unsigned int TDimension>
void
SpatialObject<TDimension>::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);
Expand All @@ -431,8 +430,7 @@ template <unsigned int TDimension>
bool
SpatialObject<TDimension>::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);
Expand Down

0 comments on commit bbeb397

Please sign in to comment.