Skip to content

Commit

Permalink
STYLE: Prefer making deleted functions public
Browse files Browse the repository at this point in the history
Deleting a function affects fundamental aspects of the client
interface of a class, and hiding them in private as if they
were implementation details is unhelpful.

Unfortunately, this was historically necessary for C++98, but no
longer required with C++11.

Co-authored-by: Hans Johnson  <hans-johnson@uiowa.edu>
  • Loading branch information
mseng10 and hjmjohnson committed Mar 4, 2020
1 parent d70b921 commit 0a4e48a
Show file tree
Hide file tree
Showing 44 changed files with 160 additions and 262 deletions.
7 changes: 2 additions & 5 deletions Modules/Bridge/VtkGlue/include/vtkCaptureScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ template <typename TImageWriter>
class vtkCaptureScreen
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(vtkCaptureScreen);

using ImageWriterType = TImageWriter;

vtkCaptureScreen(vtkRenderWindow * iRenderer)
: m_Renderer(iRenderer)
{}

vtkCaptureScreen() = default;

~vtkCaptureScreen() = default;

void
Expand All @@ -52,10 +53,6 @@ class vtkCaptureScreen
}

private:
vtkCaptureScreen(const vtkCaptureScreen &) = delete;
void
operator=(const vtkCaptureScreen &) = delete;

vtkRenderWindow * m_Renderer{ nullptr };

void
Expand Down
11 changes: 3 additions & 8 deletions Modules/Compatibility/Deprecated/include/itkTreeChangeEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ITK_TEMPLATE_EXPORT TreeChangeEvent : public ModifiedEvent
using Self = TreeChangeEvent;
using Superclass = ModifiedEvent;

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

/** Constructor */
TreeChangeEvent()
: m_ChangePosition(nullptr)
Expand Down Expand Up @@ -83,10 +86,6 @@ class ITK_TEMPLATE_EXPORT TreeChangeEvent : public ModifiedEvent

protected:
const TreeIteratorBase<TTreeType> * m_ChangePosition;

private:
void
operator=(const Self &) = delete;
};

/** \class TreeNodeChangeEvent
Expand Down Expand Up @@ -130,7 +129,6 @@ class TreeNodeChangeEvent : public TreeChangeEvent<TTreeType>
: TreeChangeEvent<TTreeType>(s)
{}

private:
void
operator=(const Self &) = delete;
};
Expand Down Expand Up @@ -180,7 +178,6 @@ class ITK_TEMPLATE_EXPORT TreeAddEvent : public TreeChangeEvent<TTreeType>
: TreeChangeEvent<TTreeType>(s)
{}

private:
void
operator=(const Self &) = delete;
};
Expand Down Expand Up @@ -230,7 +227,6 @@ class ITK_TEMPLATE_EXPORT TreeRemoveEvent : public TreeChangeEvent<TTreeType>
: TreeChangeEvent<TTreeType>(s)
{}

private:
void
operator=(const Self &) = delete;
};
Expand Down Expand Up @@ -275,7 +271,6 @@ class ITK_TEMPLATE_EXPORT TreePruneEvent : public TreeRemoveEvent<TTreeType>
: TreeRemoveEvent<TTreeType>(s)
{}

private:
void
operator=(const Self &) = delete;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ class ITK_TEMPLATE_EXPORT ConstShapedNeighborhoodIterator : private Neighborhood
: Superclass(radius, const_cast<ImageType *>(ptr), region)
{}

/** Copy constructor */
ConstShapedNeighborhoodIterator(const ConstShapedNeighborhoodIterator &) = delete;

// Expose the following methods from the superclass. This is a
// restricted subset of the methods available for
// ConstNeighborhoodIterator.
Expand Down Expand Up @@ -418,10 +421,6 @@ class ITK_TEMPLATE_EXPORT ConstShapedNeighborhoodIterator : private Neighborhood

bool m_CenterIsActive{ false };
IndexListType m_ActiveIndexList;

private:
/** Copy constructor */
ConstShapedNeighborhoodIterator(const ConstShapedNeighborhoodIterator &) = delete;
};
} // namespace itk

Expand Down
7 changes: 3 additions & 4 deletions Modules/Core/Common/include/itkEventObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class ITKCommon_EXPORT EventObject

EventObject(const EventObject &) = default;

EventObject &
operator=(const EventObject &) = delete;

/** Virtual destructor needed */
virtual ~EventObject() = default;

Expand Down Expand Up @@ -98,10 +101,6 @@ class ITKCommon_EXPORT EventObject

virtual void
PrintTrailer(std::ostream & os, Indent indent) const;

private:
void
operator=(const EventObject &) = delete;
};

/** Generic inserter operator for EventObject and its subclasses. */
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/Common/include/itkFloatingPointExceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ struct ExceptionGlobals;
class ITKCommon_EXPORT FloatingPointExceptions
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(FloatingPointExceptions);
// default constructor required for wrapping to succeed
FloatingPointExceptions() = default;
virtual ~FloatingPointExceptions() = default;

using ExceptionActionEnum = FloatingPointExceptionsEnums::ExceptionAction;
#if !defined(ITK_LEGACY_REMOVE)
/**Exposes enum values at class level for backwards compatibility*/
Expand Down Expand Up @@ -108,11 +113,6 @@ class ITKCommon_EXPORT FloatingPointExceptions
HasFloatingPointExceptionsSupport();

private:
FloatingPointExceptions() = default;
FloatingPointExceptions(const FloatingPointExceptions &) = delete;
void
operator=(const FloatingPointExceptions &) = delete;

itkGetGlobalDeclarationMacro(ExceptionGlobals, PimplGlobals);
/** static member that controls what happens during an exception */
static ExceptionGlobals * m_PimplGlobals;
Expand Down
4 changes: 0 additions & 4 deletions Modules/Core/Common/include/itkNumberToString.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ class ITK_TEMPLATE_EXPORT NumberToString
public:
std::string
operator()(TValue val);

private:
NumberToString &
operator=(const NumberToString &) = delete;
};

// declaration of specialization
Expand Down
10 changes: 2 additions & 8 deletions Modules/Core/Common/include/itkSTLConstContainerAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ template <typename TContainer>
class STLConstContainerAdaptor
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(STLConstContainerAdaptor);

using AdapteeType = const TContainer;

using ElementType = const typename AdapteeType::Element;
Expand All @@ -54,14 +56,6 @@ class STLConstContainerAdaptor
private:
AdapteeType & m_AdapteeRef;

/** hide the copy constructor to allow only direct construction of the adapter
*/
STLConstContainerAdaptor(const STLConstContainerAdaptor & r) = delete;

/* hide and avoid operator= */
const STLConstContainerAdaptor &
operator=(const STLConstContainerAdaptor & r) = delete;

public:
STLConstContainerAdaptor(AdapteeType & adaptee)
: m_AdapteeRef(adaptee)
Expand Down
10 changes: 2 additions & 8 deletions Modules/Core/Common/include/itkSTLContainerAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ template <typename TContainer>
class STLContainerAdaptor
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(STLContainerAdaptor);

using AdapteeType = TContainer;

using ElementType = typename AdapteeType::Element;
Expand All @@ -51,14 +53,6 @@ class STLContainerAdaptor
private:
AdapteeType & m_AdapteeRef;

/** hide the copy constructor to allow only direct construction of the adapter
*/
STLContainerAdaptor(const STLContainerAdaptor & r) = delete;

/* hide and avoid operator= */
const STLContainerAdaptor &
operator=(const STLContainerAdaptor & r) = delete;

public:
STLContainerAdaptor(AdapteeType & adaptee)
: m_AdapteeRef(adaptee)
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkShapedNeighborhoodIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ class ITK_TEMPLATE_EXPORT ShapedNeighborhoodIterator
/** Virtual destructor */
~ShapedNeighborhoodIterator() override = default;

/** Copy constructor */
ShapedNeighborhoodIterator(const ShapedNeighborhoodIterator & o) = delete;

/** Constructor which establishes the region size, neighborhood, and image
* over which to walk. */
ShapedNeighborhoodIterator(const SizeType & radius, const ImageType * ptr, const RegionType & region)
Expand Down Expand Up @@ -261,9 +264,6 @@ class ITK_TEMPLATE_EXPORT ShapedNeighborhoodIterator
protected:
friend Superclass;

/** Copy constructor */
ShapedNeighborhoodIterator(const ShapedNeighborhoodIterator & o) = delete;

using NeighborIndexType = typename Superclass::NeighborIndexType;
};
} // namespace itk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class ITK_TEMPLATE_EXPORT SymmetricEllipsoidInteriorExteriorSpatialFunction
: public InteriorExteriorSpatialFunction<VDimension, TInput>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(SymmetricEllipsoidInteriorExteriorSpatialFunction);

/** Standard class type aliases. */
using Self = SymmetricEllipsoidInteriorExteriorSpatialFunction;
using Superclass = InteriorExteriorSpatialFunction<VDimension>;
Expand Down Expand Up @@ -80,10 +82,6 @@ class ITK_TEMPLATE_EXPORT SymmetricEllipsoidInteriorExteriorSpatialFunction
PrintSelf(std::ostream & os, Indent indent) const override;

private:
SymmetricEllipsoidInteriorExteriorSpatialFunction(const Self &) = delete;
void
operator=(const Self &) = delete;

/** The center of the ellipsoid. */
InputType m_Center;

Expand Down
2 changes: 0 additions & 2 deletions Modules/Core/GPUCommon/include/itkGPUImageOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class GPUImageOps
/** Get OpenCL Kernel source as a string, creates a GetOpenCLSource method */
itkGetOpenCLSourceFromKernelMacro(GPUImageOpsKernel);
};


} // end of namespace itk

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class ITK_TEMPLATE_EXPORT VectorLinearInterpolateNearestNeighborExtrapolateImage
: public VectorInterpolateImageFunction<TInputImage, TCoordRep>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(VectorLinearInterpolateNearestNeighborExtrapolateImageFunction);

/** Standard class type aliases. */
using Self = VectorLinearInterpolateNearestNeighborExtrapolateImageFunction;
using Superclass = VectorInterpolateImageFunction<TInputImage, TCoordRep>;
Expand Down Expand Up @@ -139,10 +141,6 @@ class ITK_TEMPLATE_EXPORT VectorLinearInterpolateNearestNeighborExtrapolateImage
PrintSelf(std::ostream & os, Indent indent) const override;

private:
VectorLinearInterpolateNearestNeighborExtrapolateImageFunction(const Self &) = delete;
void
operator=(const Self &) = delete;

/** Number of neighbors used in the interpolation */
static const unsigned int m_Neighbors;
};
Expand Down
7 changes: 2 additions & 5 deletions Modules/Core/Mesh/include/itkInteriorExteriorMeshFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ template <typename TInputMesh, typename TOutputMesh, typename TSpatialFunction>
class ITK_TEMPLATE_EXPORT InteriorExteriorMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(InteriorExteriorMeshFilter);

/** Standard class type aliases. */
using Self = InteriorExteriorMeshFilter;
using Superclass = MeshToMeshFilter<TInputMesh, TOutputMesh>;
Expand Down Expand Up @@ -90,11 +92,6 @@ class ITK_TEMPLATE_EXPORT InteriorExteriorMeshFilter : public MeshToMeshFilter<T

/** Transform applied to all the mesh points. */
typename SpatialFunctionType::Pointer m_SpatialFunction;

private:
InteriorExteriorMeshFilter(const InteriorExteriorMeshFilter &) = delete;
void
operator=(const InteriorExteriorMeshFilter &) = delete;
};
} // end namespace itk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ template <typename TImageType>
class ITK_TEMPLATE_EXPORT PipelineMonitorImageFilter : public ImageToImageFilter<TImageType, TImageType>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(PipelineMonitorImageFilter);

using Self = PipelineMonitorImageFilter;
using Superclass = ImageToImageFilter<TImageType, TImageType>;
using Pointer = SmartPointer<Self>;
Expand Down Expand Up @@ -216,10 +218,6 @@ class ITK_TEMPLATE_EXPORT PipelineMonitorImageFilter : public ImageToImageFilter
PrintSelf(std::ostream & os, Indent indent) const override;

private:
PipelineMonitorImageFilter(const PipelineMonitorImageFilter &) = delete;
void
operator=(const PipelineMonitorImageFilter &) = delete;

bool m_ClearPipelineOnGenerateOutputInformation;

unsigned int m_NumberOfUpdates;
Expand All @@ -236,7 +234,6 @@ class ITK_TEMPLATE_EXPORT PipelineMonitorImageFilter : public ImageToImageFilter
SpacingType m_UpdatedOutputSpacing;
ImageRegionType m_UpdatedOutputLargestPossibleRegion;
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
Expand Down
7 changes: 2 additions & 5 deletions Modules/Core/Transform/include/itkAffineTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class ITK_TEMPLATE_EXPORT AffineTransform
: public MatrixOffsetTransformBase<TParametersValueType, NDimensions, NDimensions>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(AffineTransform);

/** Standard type alias */
using Self = AffineTransform;
using Superclass = MatrixOffsetTransformBase<TParametersValueType, NDimensions, NDimensions>;
Expand Down Expand Up @@ -282,11 +284,6 @@ class ITK_TEMPLATE_EXPORT AffineTransform
/** Print contents of an AffineTransform */
void
PrintSelf(std::ostream & s, Indent indent) const override;

private:
AffineTransform(const Self & other) = delete;
const Self &
operator=(const Self &) = delete;
}; // class AffineTransform

} // namespace itk
Expand Down
8 changes: 2 additions & 6 deletions Modules/Core/Transform/include/itkCenteredAffineTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ template <typename TParametersValueType = double, unsigned int NDimensions = 3>
class ITK_TEMPLATE_EXPORT CenteredAffineTransform : public AffineTransform<TParametersValueType, NDimensions>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(CenteredAffineTransform);

/** Standard type alias */
using Self = CenteredAffineTransform;
using Superclass = AffineTransform<TParametersValueType, NDimensions>;
Expand Down Expand Up @@ -116,12 +118,6 @@ class ITK_TEMPLATE_EXPORT CenteredAffineTransform : public AffineTransform<TPara

/** Destroy an CenteredAffineTransform object */
~CenteredAffineTransform() override = default;

private:
CenteredAffineTransform(const Self & other) = delete;
const Self &
operator=(const Self &) = delete;

}; // class CenteredAffineTransform
} // namespace itk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ITK_TEMPLATE_EXPORT FixedCenterOfRotationAffineTransform
: public ScalableAffineTransform<TParametersValueType, NDimensions>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(FixedCenterOfRotationAffineTransform);

/** Standard type alias */
using Self = FixedCenterOfRotationAffineTransform;
using Superclass = ScalableAffineTransform<TParametersValueType, NDimensions>;
Expand Down Expand Up @@ -123,11 +125,6 @@ class ITK_TEMPLATE_EXPORT FixedCenterOfRotationAffineTransform

/** Destroy an FixedCenterOfRotationAffineTransform object */
~FixedCenterOfRotationAffineTransform() override = default;

private:
FixedCenterOfRotationAffineTransform(const Self & other) = delete;
const Self &
operator=(const Self &) = delete;
}; // class FixedCenterOfRotationAffineTransform
} // namespace itk

Expand Down
Loading

0 comments on commit 0a4e48a

Please sign in to comment.