HomePhabricator
Diffusion MITK a720f2bed6e1

BREAKING mitk::Point conversion constructor

Description

BREAKING mitk::Point conversion constructor

Reason:
Conversion constructor "template <typename TPointValueType>
Point(const TPointValueType &v)" is not defined as explicit.
This can lead i.a. to ambiguities with overloaded functions, when one
of the parameters is of type mitk::Point.

E.g.:
myFunct(mitk::Point3D point); Overload #1
myFunct(const MyType* x);
Overload #2

The call "myFunct(ptrToInstanceOfMyTyp);" leads in some compilers
not to #2 but to #1. The pointer is tried to be implicitly converted
into a Point instance, therefore picking the wrong overload and
causing compile errors. Making the constructor explicit, such problems
are prevented and all types of conversion have to be explicit.

Hot to migrate:
If code breaks no, because the constructor is explicit now, one has to
explicitly call the constructor. E.g.:
mitk::Point2D point2D;
mitk::Point2I point2I = point2D; fails now because different value type and no implicit conversion.
mitk::Point2I point2I = Point2I(point2D);
OK
mitk::Point2I point2I(point2D); //Also OK