From 59a1f00672bba9dd32d7b229dbf142dbd2d3416e Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 12 Feb 2015 21:21:57 -0600 Subject: [PATCH] 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. --- doc/news/changes.h | 13 +++++++++++++ include/deal.II/base/point.h | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) 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; } -- 2.39.5