Skip to content

Commit

Permalink
ENH: Declare converting Point(v) constructors explicit
Browse files Browse the repository at this point in the history
Prevented implicit conversion of a value to `Point`. Aims to avoid
possible flaws, like the ones addressed by:

Pull request InsightSoftwareConsortium#3225
commit 5b71d63
"BUG: Quick-fix ContourSpatialObject::Update(), LINEAR_INTERPOLATION case"

Pull request InsightSoftwareConsortium#3228
commit 12a501c
"BUG: Fix `SetCenterInObjectSpace` calls in Registration test"

Pull request InsightSoftwareConsortium#3231
commit e4841aa
"STYLE: Clarify estimation ray position `RayCastInterpolateImageFunction`"

Deleted `Point(nullptr_t)`, especially to avoid `PointType p = 0`.
  • Loading branch information
N-Dekker committed Feb 27, 2022
1 parent 58a1267 commit 2781baa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Modules/Core/Common/include/itkPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ class ITK_TEMPLATE_EXPORT Point : public FixedArray<TCoordRep, VPointDimension>
Point(const ValueType r[VPointDimension])
: BaseArray(r)
{}
/** Pass-through constructors for single values */

/** Prevents copy-initialization from `nullptr`, as well as from `0` (NULL). */
Point(std::nullptr_t) = delete;

/** Explicit constructors for single values */
template <typename TPointValueType>
Point(const TPointValueType & v)
explicit Point(const TPointValueType & v)
: BaseArray(v)
{}
Point(const ValueType & v)
explicit Point(const ValueType & v)
: BaseArray(v)
{}

Expand Down

0 comments on commit 2781baa

Please sign in to comment.