MantisBT - ITK
View Issue Details
0008678ITKpublic2009-03-06 04:032009-04-30 04:45
Tom Vercauteren 
kentwilliams 
normalminoralways
closedfixed 
ITK-3-12 
 
0008678: operator() defined in ITK functors should be const
A reported on the list, operator() defined in ITK functors should be const:
http://public.kitware.com/pipermail/insight-users/2009-February/029212.html [^]

On Tue, Feb 24, 2009 at 8:15 AM, Julien Michel <julien.michel@c-s.fr> wrote:
> It prevents me from reusing them inside some const methods, and it looks like
> they could have been declared const without any problem. Mutable does the
> trick, but I would rather avoid it if possible.
Below is a grep on the Functor and Function namespace. Ideally, all concerned functors should be there.

grep -rl "namespace Functor" Code/

Code/Common/itkScalarToRGBPixelFunctor.txx
Code/Common/itkIndex.h
Code/Common/itkScalarToRGBPixelFunctor.h
Code/Common/itkOffset.h
Code/Review/itkSubtractConstantFromImageFilter.h
Code/Review/itkRealAndImaginaryToComplexImageFilter.h
Code/Review/itkMultiplyByConstantImageFilter.h
Code/Review/itkDivideByConstantImageFilter.h
Code/Review/itkLabelOverlayFunctor.h
Code/Review/itkAddConstantToImageFilter.h
Code/Review/itkLabelToRGBFunctor.h
Code/Review/itkComposeRGBAImageFilter.h
Code/Review/itkMagnitudeAndPhaseToComplexImageFilter.h
Code/BasicFilters/itkSignedDanielssonDistanceMapImageFilter.h
Code/BasicFilters/itkAbsoluteValueDifferenceImageFilter.h
Code/BasicFilters/itkIntensityWindowingImageFilter.h
Code/BasicFilters/itkWeightedAddImageFilter.h
Code/BasicFilters/itkCosImageFilter.h
Code/BasicFilters/itkNotImageFilter.h
Code/BasicFilters/itkInvertIntensityImageFilter.h
Code/BasicFilters/itkScalarConnectedComponentImageFilter.h
Code/BasicFilters/itkTensorRelativeAnisotropyImageFilter.h
Code/BasicFilters/itkGradientToMagnitudeImageFilter.h
Code/BasicFilters/itkSignedMaurerDistanceMapImageFilter.txx
Code/BasicFilters/itkBinaryThresholdImageFilter.h
Code/BasicFilters/itkVectorIndexSelectionCastImageFilter.h
Code/BasicFilters/itkAsinImageFilter.h
Code/BasicFilters/itkNaryMaximumImageFilter.h
Code/BasicFilters/itkBoundedReciprocalImageFilter.h
Code/BasicFilters/itkMaskNegatedImageFilter.h
Code/BasicFilters/itkTensorFractionalAnisotropyImageFilter.h
Code/BasicFilters/itkSymmetricEigenAnalysisImageFilter.h
Code/BasicFilters/itkAndImageFilter.h
Code/BasicFilters/itkBinaryMagnitudeImageFilter.h
Code/BasicFilters/itkSquaredDifferenceImageFilter.h
Code/BasicFilters/itkConstrainedValueDifferenceImageFilter.h
Code/BasicFilters/itkMaskImageFilter.h
Code/BasicFilters/itkRescaleIntensityImageFilter.h
Code/BasicFilters/itkOrImageFilter.h
Code/BasicFilters/itkConstrainedValueAdditionImageFilter.h
Code/BasicFilters/itkEdgePotentialImageFilter.h
Code/BasicFilters/itkThresholdLabelerImageFilter.h
Code/BasicFilters/itkAdaptImageFilter.h
Code/BasicFilters/itkAtanImageFilter.h
Code/BasicFilters/itkJoinImageFilter.h
Code/BasicFilters/itkAtan2ImageFilter.h
Code/BasicFilters/itkVectorRescaleIntensityImageFilter.h
Code/BasicFilters/itkVectorConnectedComponentImageFilter.h
Code/BasicFilters/itkNaryAddImageFilter.h
Code/BasicFilters/itkAcosImageFilter.h
Code/BasicFilters/itkVectorCastImageFilter.h
Code/BasicFilters/itkCastImageFilter.h
Code/BasicFilters/itkAddImageFilter.h
Code/BasicFilters/itkMatrixIndexSelectionImageFilter.h
Code/BasicFilters/itkModulusImageFilter.h
Code/BasicFilters/itkChangeLabelImageFilter.h
Code/BasicFilters/itkXorImageFilter.h



grep -rl "namespace Function" Code/

Code/Numerics/Statistics/itkHistogramToEntropyImageFilter.h
Code/Numerics/Statistics/itkHistogramToIntensityImageFilter.h
Code/Numerics/Statistics/itkHistogramToLogProbabilityImageFilter.h
Code/Numerics/Statistics/itkHistogramToProbabilityImageFilter.h
Code/Common/itkWindowedSincInterpolateImageFunction.txx
Code/Common/itkSpatialOrientationAdapter.h
Code/Common/itkWindowedSincInterpolateImageFunction.h
Code/Review/itkMovingHistogramMorphologicalGradientImageFilter.h
Code/Review/itkMovingHistogramMorphologyImageFilter.h
Code/BasicFilters/itkLog10ImageFilter.h
Code/BasicFilters/itkLogImageFilter.h
Code/BasicFilters/itkComplexToPhaseImageFilter.h
Code/BasicFilters/itkTanImageFilter.h
Code/BasicFilters/itkStandardDeviationProjectionImageFilter.h
Code/BasicFilters/itkCompose2DVectorImageFilter.h
Code/BasicFilters/itkBinaryProjectionImageFilter.h
Code/BasicFilters/itkRGBToLuminanceImageFilter.h
Code/BasicFilters/itkCompose3DCovariantVectorImageFilter.h
Code/BasicFilters/itkBinaryThresholdProjectionImageFilter.h
Code/BasicFilters/itkTernaryAddImageFilter.h
Code/BasicFilters/itkSinImageFilter.h
Code/BasicFilters/itkMedianProjectionImageFilter.h
Code/BasicFilters/itkSqrtImageFilter.h
Code/BasicFilters/itkAbsImageFilter.h
Code/BasicFilters/itkExpImageFilter.h
Code/BasicFilters/itkTernaryMagnitudeSquaredImageFilter.h
Code/BasicFilters/itkMinimumProjectionImageFilter.h
Code/BasicFilters/itkDivideImageFilter.h
Code/BasicFilters/itkMultiplyImageFilter.h
Code/BasicFilters/itkCompose2DCovariantVectorImageFilter.h
Code/BasicFilters/itkSquareImageFilter.h
Code/BasicFilters/itkComposeRGBImageFilter.h
Code/BasicFilters/itkComplexToImaginaryImageFilter.h
Code/BasicFilters/itkMeanProjectionImageFilter.h
Code/BasicFilters/itkCompose3DVectorImageFilter.h
Code/BasicFilters/itkMaximumImageFilter.h
Code/BasicFilters/itkTernaryMagnitudeImageFilter.h
Code/BasicFilters/itkComplexToRealImageFilter.h
Code/BasicFilters/itkComplexToModulusImageFilter.h
Code/BasicFilters/itkMaximumProjectionImageFilter.h
Code/BasicFilters/itkSigmoidImageFilter.h
Code/BasicFilters/itkSubtractImageFilter.h
Code/BasicFilters/itkMinimumImageFilter.h
Code/BasicFilters/itkSumProjectionImageFilter.h
Code/BasicFilters/itkExpNegativeImageFilter.h
No tags attached.
Issue History
2009-03-06 04:03Tom VercauterenNew Issue
2009-03-06 04:05Tom VercauterenNote Added: 0015588
2009-03-26 18:08kentwilliamsNote Added: 0015808
2009-03-27 17:38kentwilliamsStatusnew => assigned
2009-03-27 17:38kentwilliamsAssigned To => kentwilliams
2009-03-27 17:39kentwilliamsNote Added: 0015817
2009-03-30 07:32Tom VercauterenNote Added: 0015846
2009-03-31 13:59kentwilliamsNote Added: 0015864
2009-03-31 13:59kentwilliamsStatusassigned => resolved
2009-03-31 13:59kentwilliamsResolutionopen => fixed
2009-04-30 04:45Tom VercauterenStatusresolved => closed

Notes
(0015588)
Tom Vercauteren   
2009-03-06 04:05   
A patch was committed on Feb 24, 2009 for the functors in the Review directory.
(0015808)
kentwilliams   
2009-03-26 18:08   
Tom, maybe we should bring up moving these out of review on the developer list?
(0015817)
kentwilliams   
2009-03-27 17:39   
itkChangeLabelImageFilter -- the ChangeLabel functor refuses to allow operator() to be const. Will look at fixing after other cases.
(0015846)
Tom Vercauteren   
2009-03-30 07:32   
Patched ChangeLabelImageFilter to make operator() const:
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/BasicFilters/itkChangeLabelImageFilter.h?root=Insight&r1=1.6&r2=1.7&sortby=date [^]

It needed a little work because according to http://www.sgi.com/tech/stl/Map.html: [^]
"Since operator[] might insert a new element into the map, it can't possibly be a const member function. Note that the definition of operator[] is extremely simple: m[k] is equivalent to (*((m.insert(value_type(k, data_type()))).first)).second. Strictly speaking, this member function is unnecessary: it exists only for convenience."
(0015864)
kentwilliams   
2009-03-31 13:59   
I checked in fixes for all such classes.