Skip to content

Commit

Permalink
STYLE: Let assignment operators return a non-const reference
Browse files Browse the repository at this point in the history
Removed the "const" from `const Self &` return types of assignment
operators.

In accordance with C++ Core Guidelines, January 3, 2022: "Make copy
assignment non-virtual, take the parameter by const&, and return by
non-const&"
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c60-make-copy-assignment-non-virtual-take-the-parameter-by-const-and-return-by-non-const
  • Loading branch information
N-Dekker authored and hjmjohnson committed Feb 11, 2022
1 parent b0a86de commit 61367f5
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ class ITK_TEMPLATE_EXPORT Array : public vnl_vector<TValue>
}

/** Copy operator */
const Self &
Self &
operator=(const Self & rhs);

const Self &
Self &
operator=(const VnlVectorType & rhs);

/** Return the number of elements in the Array */
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkArray.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Array<TValue>::SetSize(SizeValueType sz)

template <typename TValue>
auto
Array<TValue>::operator=(const Self & rhs) -> const Self &
Array<TValue>::operator=(const Self & rhs) -> Self &
{
if (this != &rhs)
{
Expand All @@ -167,7 +167,7 @@ Array<TValue>::operator=(const Self & rhs) -> const Self &

template <typename TValue>
auto
Array<TValue>::operator=(const VnlVectorType & rhs) -> const Self &
Array<TValue>::operator=(const VnlVectorType & rhs) -> Self &
{
if (this != &rhs)
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkArray2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class ITK_TEMPLATE_EXPORT Array2D : public vnl_matrix<TValue>
Array2D(const Self & array);
Array2D(const VnlMatrixType & matrix);

const Self &
Self &
operator=(const Self & array);

const Self &
Self &
operator=(const VnlMatrixType & matrix);

void
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkArray2D.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Array2D<TValue>::Array2D(const Self & array)

/** Assignment Operator from Array */
template <typename TValue>
const Array2D<TValue> &
Array2D<TValue> &
Array2D<TValue>::operator=(const Self & array)
{
this->VnlMatrixType::operator=(array);
Expand All @@ -51,7 +51,7 @@ Array2D<TValue>::operator=(const Self & array)

/** Assignment Operator from vnl_matrix */
template <typename TValue>
const Array2D<TValue> &
Array2D<TValue> &
Array2D<TValue>::operator=(const VnlMatrixType & matrix)
{
this->VnlMatrixType::operator=(matrix);
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ITK_TEMPLATE_EXPORT Matrix
}

/** Assignment operator. */
inline const Self &
inline Self &
operator=(const vnl_matrix<T> & matrix)
{
m_Matrix = matrix;
Expand Down Expand Up @@ -247,7 +247,7 @@ class ITK_TEMPLATE_EXPORT Matrix
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self);


inline const Self &
inline Self &
operator=(const InternalMatrixType & matrix)
{
this->m_Matrix = matrix;
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkOptimizerParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ITK_TEMPLATE_EXPORT OptimizerParameters : public Array<TParametersValueTyp
* TODO Determine behavior when copying from obj pointing to image parameters.
* By default should copy image param data into Array portion of new object,
* i.e. into data_block. Is that what we want? */
const Self &
Self &
operator=(const Self & rhs)
{
// Note: there's no need to copy the OptimizerParametersHelper.
Expand All @@ -163,15 +163,15 @@ class ITK_TEMPLATE_EXPORT OptimizerParameters : public Array<TParametersValueTyp
return *this;
}

const Self &
Self &
operator=(const ArrayType & rhs)
{
// Call the superclass implementation
this->ArrayType::operator=(rhs);
return *this;
}

const Self &
Self &
operator=(const VnlVectorType & rhs)
{
// Call the superclass implementation
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkVariableSizeMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class ITK_TEMPLATE_EXPORT VariableSizeMatrix
}

/** Assignment operator. */
inline const Self &
inline Self &
operator=(const vnl_matrix<T> & matrix)
{
m_Matrix = matrix;
Expand All @@ -189,7 +189,7 @@ class ITK_TEMPLATE_EXPORT VariableSizeMatrix
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self);

/** Assignment operator. */
inline const Self &
inline Self &
operator=(const Self & matrix)
{
m_Matrix = matrix.m_Matrix;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkVersor.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ITK_TEMPLATE_EXPORT Versor
Versor(const Self & v);

/** Assignment operator =. Copy the versor argument. */
const Self &
Self &
operator=(const Self & v);

/** Composition operator *=. Compose the current versor
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkVersor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Versor<T>::Versor(const Self & v)

/** Assignment Operator */
template <typename T>
const Versor<T> &
Versor<T> &
Versor<T>::operator=(const Self & v)
{
m_X = v.m_X;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class ITK_TEMPLATE_EXPORT FastMarchingImageFilter : public ImageToImageFilter<TS
{
m_Axis = axis;
}
const AxisNodeType &
AxisNodeType &
operator=(const NodeType & node)
{
this->NodeType::operator=(node);
Expand Down

0 comments on commit 61367f5

Please sign in to comment.