From: Wolfgang Bangerth Date: Fri, 13 Feb 2015 03:21:57 +0000 (-0600) Subject: Do not allow for implicit casts from Tensor to Point. X-Git-Tag: v8.3.0-rc1~467^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F531%2Fhead;p=dealii.git Do not allow for implicit casts from Tensor to Point. These are likely invalid uses of class Point and should use Tensor instead. At the same time, still allow for explicit casts. --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 2106353a8e..39e0636716 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -38,6 +38,19 @@ inconvenience this causes.

    +
  1. Changed: Implicit conversion from Tensor@<1,dim@> to Point@ was + previously possible. This has now been prohibited (but you can still + do the conversion with an explicit cast) as such conversions are + likely incorrect uses of class Point (which should represent only + points in space, i.e., vectors anchored at the origin) whereas Tensor + should be used for vectors anchored elsewhere (such as normal vectors, + directions, differences between points, etc). The difference in + usage between Point and Tensor have now been clarified in the documentation + of class Point. +
    + (Wolfgang Bangerth, 2015/01/12) +
  2. +
  3. Changed: The project configuration no longer exports [...]/include/deal.II. Thus it is now mandatory to prefix all includes of deal.II headers with deal.II/, i.e. diff --git a/include/deal.II/base/point.h b/include/deal.II/base/point.h index 75a1062673..ebb244e819 100644 --- a/include/deal.II/base/point.h +++ b/include/deal.II/base/point.h @@ -90,7 +90,7 @@ public: /** * Convert a tensor to a point. */ - Point (const Tensor<1,dim,Number> &); + explicit Point (const Tensor<1,dim,Number> &); /** * Constructor for one dimensional points. This function is only implemented @@ -324,7 +324,9 @@ inline Point Point::operator + (const Tensor<1,dim,Number> &p) const { - return (Point(*this) += p); + Point tmp = *this; + tmp += p; + return tmp; } @@ -344,7 +346,9 @@ inline Point Point::operator - (const Tensor<1,dim,Number> &p) const { - return (Point(*this) -= p); + Point tmp = *this; + tmp -= p; + return tmp; } @@ -367,7 +371,9 @@ inline Point Point::operator * (const Number factor) const { - return (Point(*this) *= factor); + Point tmp = *this; + tmp *= factor; + return tmp; } @@ -416,7 +422,9 @@ template inline Point Point::operator / (const Number factor) const { - return (Point(*this) /= factor); + Point tmp = *this; + tmp /= factor; + return tmp; }