Skip to content

Commit

Permalink
COMP: Use trailing return type instead of typename + dependent type
Browse files Browse the repository at this point in the history
Modernized template member function definitions in "itk*.hxx" files by
using trailing return types, specifically for return types that are
themselves specified in terms of a member type, dependent on the
specific class template.

These changes appeared to serve as a workaround to VS2017 compile errors
(apparently caused by a compiler bug) saying:

> error C2244: unable to match function definition to an existing declaration

By Notepad++ v8.1.4, Find in Files:

    Find what: ^typename (\w+<.+>::)(.+)\r\n\1(.+)\r\n{\r\n
    Replace with: auto\r\n$1$3 -> $2\r\n{\r\n
    Filter: itk*.hxx
    [v] Match case
    (*) Regular expression

Manually fixed `PatchBasedDenoisingBaseImageFilter::GetPatchLengthInVoxels()`.
Manually added `typename` to trailing return types, where necessary.
  • Loading branch information
N-Dekker authored and dzenanz committed Oct 5, 2021
1 parent 066ddb8 commit c54ad67
Show file tree
Hide file tree
Showing 412 changed files with 2,212 additions and 2,027 deletions.
3 changes: 2 additions & 1 deletion Modules/Bridge/NumPy/include/itkPyBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ PyBuffer<TImage>::_GetArrayViewFromImage(ImageType * image)
}

template <class TImage>
const typename PyBuffer<TImage>::OutputImagePointer
auto
PyBuffer<TImage>::_GetImageViewFromArray(PyObject * arr, PyObject * shape, PyObject * numOfComponent)
-> const OutputImagePointer
{
PyObject * shapeseq = NULL;
PyObject * item = NULL;
Expand Down
5 changes: 3 additions & 2 deletions Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ PyVectorContainer<TElementIdentifier, TElement>::_array_view_from_vector_contain
}

template <typename TElementIdentifier, typename TElement>
const typename PyVectorContainer<TElementIdentifier, TElement>::VectorContainerType::Pointer
PyVectorContainer<TElementIdentifier, TElement>::_vector_container_from_array(PyObject * arr, PyObject * shape)
auto
PyVectorContainer<TElementIdentifier, TElement>::_vector_container_from_array(PyObject * arr, PyObject * shape) -> const
typename VectorContainerType::Pointer
{
PyObject * obj = NULL;
PyObject * shapeseq = NULL;
Expand Down
8 changes: 4 additions & 4 deletions Modules/Bridge/NumPy/include/itkPyVnl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ PyVnl<TElement>::_GetArrayViewFromVnlVector(VectorType * vector)
}

template <class TElement>
const typename PyVnl<TElement>::VectorType
PyVnl<TElement>::_GetVnlVectorFromArray(PyObject * arr, PyObject * shape)
auto
PyVnl<TElement>::_GetVnlVectorFromArray(PyObject * arr, PyObject * shape) -> const VectorType
{
PyObject * obj = NULL;
PyObject * shapeseq = NULL;
Expand Down Expand Up @@ -144,8 +144,8 @@ PyVnl<TElement>::_GetArrayViewFromVnlMatrix(MatrixType * matrix)
}

template <class TElement>
const typename PyVnl<TElement>::MatrixType
PyVnl<TElement>::_GetVnlMatrixFromArray(PyObject * arr, PyObject * shape)
auto
PyVnl<TElement>::_GetVnlMatrixFromArray(PyObject * arr, PyObject * shape) -> const MatrixType
{
PyObject * obj = NULL;
PyObject * shapeseq = NULL;
Expand Down
4 changes: 2 additions & 2 deletions Modules/Bridge/VTK/include/itkVTKImageExport.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ VTKImageExport<TInputImage>::SetInput(const InputImageType * input)
* Get the current input image.
*/
template <typename TInputImage>
typename VTKImageExport<TInputImage>::InputImageType *
VTKImageExport<TInputImage>::GetInput()
auto
VTKImageExport<TInputImage>::GetInput() -> InputImageType *
{
return itkDynamicCastInDebugMode<TInputImage *>(this->ProcessObject::GetInput(0));
}
Expand Down
8 changes: 4 additions & 4 deletions Modules/Bridge/VtkGlue/include/itkImageToVTKImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ ImageToVTKImageFilter<TInputImage>::SetInput(const InputImageType * inputImage)
}

template <typename TInputImage>
typename ImageToVTKImageFilter<TInputImage>::InputImageType *
ImageToVTKImageFilter<TInputImage>::GetInput()
auto
ImageToVTKImageFilter<TInputImage>::GetInput() -> InputImageType *
{
return m_Exporter->GetInput();
}
Expand Down Expand Up @@ -103,8 +103,8 @@ ImageToVTKImageFilter<TInputImage>::GetImporter() const
* Get the exporter filter
*/
template <typename TInputImage>
typename ImageToVTKImageFilter<TInputImage>::ExporterFilterType *
ImageToVTKImageFilter<TInputImage>::GetExporter() const
auto
ImageToVTKImageFilter<TInputImage>::GetExporter() const -> ExporterFilterType *
{
return m_Exporter.GetPointer();
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/Bridge/VtkGlue/include/itkVTKImageToImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ VTKImageToImageFilter<TOutputImage>::GetExporter() const
* Get the importer filter
*/
template <typename TOutputImage>
const typename VTKImageToImageFilter<TOutputImage>::Superclass *
VTKImageToImageFilter<TOutputImage>::GetImporter() const
auto
VTKImageToImageFilter<TOutputImage>::GetImporter() const -> const Superclass *
{
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ ChildTreeIterator<TTreeType>::GoToParent()

/** Return the type of the iterator */
template <typename TTreeType>
typename ChildTreeIterator<TTreeType>::NodeType
ChildTreeIterator<TTreeType>::GetType() const
auto
ChildTreeIterator<TTreeType>::GetType() const -> NodeType
{
return TreeIteratorBaseEnums::TreeIteratorBaseNode::CHILD;
}
Expand All @@ -104,8 +104,8 @@ ChildTreeIterator<TTreeType>::HasNext() const

/** Return the next node */
template <typename TTreeType>
const typename ChildTreeIterator<TTreeType>::ValueType &
ChildTreeIterator<TTreeType>::Next()
auto
ChildTreeIterator<TTreeType>::Next() -> const ValueType &
{
m_ListPosition++;
this->m_Position = m_ParentNode->GetChild(m_ListPosition);
Expand Down
12 changes: 6 additions & 6 deletions Modules/Compatibility/Deprecated/include/itkImageTransformer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ ImageTransformer<TInputImage>::SetInput(unsigned int index, const TInputImage *
*
*/
template <typename TInputImage>
const typename ImageTransformer<TInputImage>::InputImageType *
ImageTransformer<TInputImage>::GetInput() const
auto
ImageTransformer<TInputImage>::GetInput() const -> const InputImageType *
{
if (this->GetNumberOfInputs() < 1)
{
Expand All @@ -86,8 +86,8 @@ ImageTransformer<TInputImage>::GetInput() const
*
*/
template <typename TInputImage>
typename ImageTransformer<TInputImage>::InputImageType *
ImageTransformer<TInputImage>::GetInput()
auto
ImageTransformer<TInputImage>::GetInput() -> InputImageType *
{
if (this->GetNumberOfInputs() < 1)
{
Expand All @@ -101,8 +101,8 @@ ImageTransformer<TInputImage>::GetInput()
*
*/
template <typename TInputImage>
const typename ImageTransformer<TInputImage>::InputImageType *
ImageTransformer<TInputImage>::GetInput(unsigned int idx) const
auto
ImageTransformer<TInputImage>::GetInput(unsigned int idx) const -> const InputImageType *
{
return itkDynamicCastInDebugMode<const TInputImage *>(this->ProcessObject::GetInput(idx));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ LevelOrderTreeIterator<TTreeType>::LevelOrderTreeIterator(TTreeType * t

/** Return the type of iterator */
template <typename TTreeType>
typename LevelOrderTreeIterator<TTreeType>::NodeType
LevelOrderTreeIterator<TTreeType>::GetType() const
auto
LevelOrderTreeIterator<TTreeType>::GetType() const -> NodeType
{
return TreeIteratorBaseEnums::TreeIteratorBaseNode::LEVELORDER;
}
Expand All @@ -93,8 +93,8 @@ LevelOrderTreeIterator<TTreeType>::HasNext() const

/** Return the next node */
template <typename TTreeType>
const typename LevelOrderTreeIterator<TTreeType>::ValueType &
LevelOrderTreeIterator<TTreeType>::Next()
auto
LevelOrderTreeIterator<TTreeType>::Next() -> const ValueType &
{
this->m_Position = const_cast<TreeNodeType *>(FindNextNode());
if (this->m_Position == nullptr)
Expand Down Expand Up @@ -122,8 +122,8 @@ LevelOrderTreeIterator<TTreeType>::GetEndLevel() const

/** Find the next available node */
template <typename TTreeType>
const typename LevelOrderTreeIterator<TTreeType>::TreeNodeType *
LevelOrderTreeIterator<TTreeType>::FindNextNode() const
auto
LevelOrderTreeIterator<TTreeType>::FindNextNode() const -> const TreeNodeType *
{
int level;
const TreeNodeType * node;
Expand Down Expand Up @@ -186,8 +186,8 @@ LevelOrderTreeIterator<TTreeType>::GetLevel(const TreeNodeType * node) const

/** Helper function to find the next node */
template <typename TTreeType>
const typename LevelOrderTreeIterator<TTreeType>::TreeNodeType *
LevelOrderTreeIterator<TTreeType>::FindNextNodeHelp() const
auto
LevelOrderTreeIterator<TTreeType>::FindNextNodeHelp() const -> const TreeNodeType *
{
if (m_Queue.empty())
{
Expand Down
24 changes: 12 additions & 12 deletions Modules/Compatibility/Deprecated/include/itkTreeIteratorBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ TreeIteratorBase<TTreeType>::TreeIteratorBase(const TTreeType * tree, const Tree

/** Return the current value of the node */
template <typename TTreeType>
const typename TreeIteratorBase<TTreeType>::ValueType &
TreeIteratorBase<TTreeType>::Get() const
auto
TreeIteratorBase<TTreeType>::Get() const -> const ValueType &
{
return m_Position->Get();
}
Expand Down Expand Up @@ -342,8 +342,8 @@ TreeIteratorBase<TTreeType>::Children()

/** Return the first parent found */
template <typename TTreeType>
const typename TreeIteratorBase<TTreeType>::TreeNodeType *
TreeIteratorBase<TTreeType>::GetParent() const
auto
TreeIteratorBase<TTreeType>::GetParent() const -> const TreeNodeType *
{
if (m_Position == nullptr)
{
Expand Down Expand Up @@ -445,32 +445,32 @@ TreeIteratorBase<TTreeType>::Count()

/** Get the node pointed by the iterator */
template <typename TTreeType>
typename TreeIteratorBase<TTreeType>::TreeNodeType *
TreeIteratorBase<TTreeType>::GetNode()
auto
TreeIteratorBase<TTreeType>::GetNode() -> TreeNodeType *
{
return const_cast<TreeNodeType *>(m_Position);
}

/** Get the node pointed by the iterator */
template <typename TTreeType>
const typename TreeIteratorBase<TTreeType>::TreeNodeType *
TreeIteratorBase<TTreeType>::GetNode() const
auto
TreeIteratorBase<TTreeType>::GetNode() const -> const TreeNodeType *
{
return m_Position;
}

/** Get the root */
template <typename TTreeType>
typename TreeIteratorBase<TTreeType>::TreeNodeType *
TreeIteratorBase<TTreeType>::GetRoot()
auto
TreeIteratorBase<TTreeType>::GetRoot() -> TreeNodeType *
{
return const_cast<TreeNodeType *>(m_Root);
}

/** Get the root (const) */
template <typename TTreeType>
const typename TreeIteratorBase<TTreeType>::TreeNodeType *
TreeIteratorBase<TTreeType>::GetRoot() const
auto
TreeIteratorBase<TTreeType>::GetRoot() const -> const TreeNodeType *
{
return m_Root;
}
Expand Down
16 changes: 8 additions & 8 deletions Modules/Compatibility/Deprecated/include/itkTreeNode.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ TreeNode<TValue>::HasChildren() const

/** Return the number of children */
template <typename TValue>
typename TreeNode<TValue>::ChildIdentifier
TreeNode<TValue>::CountChildren() const
auto
TreeNode<TValue>::CountChildren() const -> ChildIdentifier
{
return static_cast<ChildIdentifier>(m_Children.size());
}
Expand Down Expand Up @@ -183,8 +183,8 @@ TreeNode<TValue>::ChildPosition(const Self * node) const

/** Return the child position given an element, the first child found. */
template <typename TValue>
typename TreeNode<TValue>::ChildIdentifier
TreeNode<TValue>::ChildPosition(TValue element) const
auto
TreeNode<TValue>::ChildPosition(TValue element) const -> ChildIdentifier
{
const auto numberOfChildren = static_cast<ChildIdentifier>(m_Children.size());

Expand Down Expand Up @@ -233,8 +233,8 @@ TreeNode<TValue>::AddChild(ChildIdentifier number, Self * node)

/** Get the number of children given a name and a depth */
template <typename TValue>
typename TreeNode<TValue>::ChildIdentifier
TreeNode<TValue>::GetNumberOfChildren(unsigned int depth, char * name) const
auto
TreeNode<TValue>::GetNumberOfChildren(unsigned int depth, char * name) const -> ChildIdentifier
{
auto it = m_Children.begin();
auto itEnd = m_Children.end();
Expand Down Expand Up @@ -266,8 +266,8 @@ TreeNode<TValue>::GetNumberOfChildren(unsigned int depth, char * name) const
/** Get children given a name and a depth */
#if !defined(ITK_WRAPPING_PARSER)
template <typename TValue>
typename TreeNode<TValue>::ChildrenListType *
TreeNode<TValue>::GetChildren(unsigned int depth, char * name) const
auto
TreeNode<TValue>::GetChildren(unsigned int depth, char * name) const -> ChildrenListType *
{
auto * children = new ChildrenListType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ VectorCentralDifferenceImageFunction<TInputImage, TCoordRep>::PrintSelf(std::ost
*
*/
template <typename TInputImage, typename TCoordRep>
typename VectorCentralDifferenceImageFunction<TInputImage, TCoordRep>::OutputType
auto
VectorCentralDifferenceImageFunction<TInputImage, TCoordRep>::EvaluateAtIndex(const IndexType & index) const
-> OutputType
{
OutputType derivative;

Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkAnnulusOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ AnnulusOperator<TPixel, TDimension, TAllocator>::Fill(const CoefficientVector &
}

template <typename TPixel, unsigned int TDimension, typename TAllocator>
typename AnnulusOperator<TPixel, TDimension, TAllocator>::CoefficientVector
AnnulusOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients()
auto
AnnulusOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients() -> CoefficientVector
{
// Determine the initial kernel values...
double interiorV, annulusV, exteriorV;
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkArray.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ Array<TValue>::SetSize(SizeValueType sz)
}

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

template <typename TValue>
const typename Array<TValue>::Self &
Array<TValue>::operator=(const VnlVectorType & rhs)
auto
Array<TValue>::operator=(const VnlVectorType & rhs) -> const Self &
{
if (this != &rhs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ namespace itk
{

template <typename TInput, typename TOutput>
typename AtanRegularizedHeavisideStepFunction<TInput, TOutput>::OutputType
AtanRegularizedHeavisideStepFunction<TInput, TOutput>::Evaluate(const InputType & input) const
auto
AtanRegularizedHeavisideStepFunction<TInput, TOutput>::Evaluate(const InputType & input) const -> OutputType
{
const RealType t = static_cast<RealType>(input) * this->GetOneOverEpsilon();
return 0.5 + static_cast<OutputType>(itk::Math::one_over_pi * std::atan(t));
}

/** Evaluate the derivative at the specified input position */
template <typename TInput, typename TOutput>
typename AtanRegularizedHeavisideStepFunction<TInput, TOutput>::OutputType
AtanRegularizedHeavisideStepFunction<TInput, TOutput>::EvaluateDerivative(const InputType & input) const
auto
AtanRegularizedHeavisideStepFunction<TInput, TOutput>::EvaluateDerivative(const InputType & input) const -> OutputType
{
const RealType oneOverEpsilon = this->GetOneOverEpsilon();
const RealType t = static_cast<RealType>(input) * oneOverEpsilon;
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkBackwardDifferenceOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
namespace itk
{
template <typename TPixel, unsigned int TDimension, typename TAllocator>
typename BackwardDifferenceOperator<TPixel, TDimension, TAllocator>::CoefficientVector
BackwardDifferenceOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients()
auto
BackwardDifferenceOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients() -> CoefficientVector
{
CoefficientVector coeff(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ BinaryThresholdSpatialFunction<TFunction>::PrintSelf(std::ostream & os, Indent i
}

template <typename TFunction>
typename BinaryThresholdSpatialFunction<TFunction>::OutputType
BinaryThresholdSpatialFunction<TFunction>::Evaluate(const InputType & point) const
auto
BinaryThresholdSpatialFunction<TFunction>::Evaluate(const InputType & point) const -> OutputType
{
FunctionOutputType value = m_Function->Evaluate(point);

Expand Down
Loading

0 comments on commit c54ad67

Please sign in to comment.