Skip to content

Commit

Permalink
STYLE: Default constructors VectorContainer, Iterator, ConstIterator
Browse files Browse the repository at this point in the history
Defaulted the default-constructors of `VectorContainer`,
`VectorContainer::Iterator`, and `VectorContainer::ConstIterator`. Added
in-class default member initializers to their member variables.

Added `[[maybe_unused]]` attributes to itkVectorContainerTest, to avoid Clang
warnings ("unused variable 'p_null' [-Wunused-variable]") which would otherwise
appear when defaulting those default-constructors.
  • Loading branch information
N-Dekker committed Sep 21, 2023
1 parent a4a46cc commit 824b041
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
21 changes: 7 additions & 14 deletions Modules/Core/Common/include/itkVectorContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ class ITK_TEMPLATE_EXPORT VectorContainer
/** Provide pass-through constructors corresponding to all the STL
* vector constructors. These are for internal use only since this is also
* an Object which must be constructed through the "New()" routine. */
VectorContainer()
: Object()
, VectorType()
{}
VectorContainer() = default;
VectorContainer(size_type n)
: Object()
, VectorType(n)
Expand Down Expand Up @@ -185,9 +182,7 @@ class ITK_TEMPLATE_EXPORT VectorContainer
using pointer = typename VectorIterator::pointer;
using reference = typename VectorIterator::reference;

Iterator()
: m_Pos(0)
{}
Iterator() = default;
Iterator(size_type d, const VectorIterator & i)
: m_Pos(d)
, m_Iter(i)
Expand Down Expand Up @@ -292,8 +287,8 @@ class ITK_TEMPLATE_EXPORT VectorContainer
}

private:
size_type m_Pos;
VectorIterator m_Iter;
size_type m_Pos{};
VectorIterator m_Iter{};
friend class ConstIterator;
};

Expand All @@ -311,9 +306,7 @@ class ITK_TEMPLATE_EXPORT VectorContainer
using pointer = typename VectorConstIterator::pointer;
using reference = typename VectorConstIterator::reference;

ConstIterator()
: m_Pos(0)
{}
ConstIterator() = default;
ConstIterator(size_type d, const VectorConstIterator & i)
: m_Pos(d)
, m_Iter(i)
Expand Down Expand Up @@ -428,8 +421,8 @@ class ITK_TEMPLATE_EXPORT VectorContainer
}

private:
size_type m_Pos;
VectorConstIterator m_Iter;
size_type m_Pos{};
VectorConstIterator m_Iter{};
friend class Iterator;
};

Expand Down
16 changes: 8 additions & 8 deletions Modules/Core/Common/test/itkVectorContainerTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ itkVectorContainerTest(int, char *[])

// Iterator
{
ContainerType::Iterator p_null;
ContainerType::Iterator p = container->Begin();
ContainerType::Iterator p_copy(p);
ContainerType::Iterator p_assign = p;
[[maybe_unused]] ContainerType::Iterator p_null;
ContainerType::Iterator p = container->Begin();
ContainerType::Iterator p_copy(p);
ContainerType::Iterator p_assign = p;

while (p != container->End())
{
Expand All @@ -51,10 +51,10 @@ itkVectorContainerTest(int, char *[])

// ConstIterator
{
ContainerType::ConstIterator p_null;
ContainerType::ConstIterator p = container->Begin();
ContainerType::ConstIterator p_copy(p);
ContainerType::ConstIterator p_assign = p;
[[maybe_unused]] ContainerType::ConstIterator p_null;
ContainerType::ConstIterator p = container->Begin();
ContainerType::ConstIterator p_copy(p);
ContainerType::ConstIterator p_assign = p;

while (p != container->End())
{
Expand Down

0 comments on commit 824b041

Please sign in to comment.