From 75fa32760332e22fb5f1907a6ddaa3711de94fb2 Mon Sep 17 00:00:00 2001 From: Matthias Maier <tamiko@43-1.org> Date: Thu, 3 Sep 2015 07:54:41 +0200 Subject: [PATCH] Bugfix: Avoid C++11 features Do not use template default arguments for function templates. Also provide fully templated interface for scalar multiplication with point, too. --- include/deal.II/base/point.h | 56 +++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/include/deal.II/base/point.h b/include/deal.II/base/point.h index a51b5678a3..723a339a8e 100644 --- a/include/deal.II/base/point.h +++ b/include/deal.II/base/point.h @@ -199,15 +199,16 @@ public: * * @relates EnableIfScalar */ - template <typename OtherNumber, - typename = typename EnableIfScalar<OtherNumber>::type> - Point<dim,Number> operator * (const OtherNumber) const; + template <typename OtherNumber> + Point<dim,typename ProductType<Number, typename EnableIfScalar<OtherNumber>::type>::type> + operator * (const OtherNumber) const; /** * Divide the current point by a factor. */ - template<typename OtherNumber> - Point<dim,Number> operator / (const OtherNumber) const; + template <typename OtherNumber> + Point<dim,typename ProductType<Number, typename EnableIfScalar<OtherNumber>::type>::type> + operator / (const OtherNumber) const; /** * Return the scalar product of the vectors representing two points. @@ -396,13 +397,28 @@ Point<dim,Number>::operator - () const template <int dim, typename Number> -template<typename OtherNumber, typename> +template<typename OtherNumber> inline -Point<dim,Number> +Point<dim,typename ProductType<Number, typename EnableIfScalar<OtherNumber>::type>::type> Point<dim,Number>::operator * (const OtherNumber factor) const { - Point<dim,Number> tmp = *this; - tmp *= factor; + Point<dim,typename ProductType<Number, OtherNumber>::type> tmp; + for (unsigned int i=0; i<dim; ++i) + tmp[i] = this->operator[](i) * factor; + return tmp; +} + + + +template <int dim, typename Number> +template<typename OtherNumber> +inline +Point<dim,typename ProductType<Number, typename EnableIfScalar<OtherNumber>::type>::type> +Point<dim,Number>::operator / (const OtherNumber factor) const +{ + Point<dim,typename ProductType<Number, OtherNumber>::type> tmp; + for (unsigned int i=0; i<dim; ++i) + tmp[i] = this->operator[](i) / factor; return tmp; } @@ -450,18 +466,6 @@ Point<dim,Number>::distance (const Point<dim,Number> &p) const -template <int dim, typename Number> -template<typename OtherNumber> -inline -Point<dim,Number> Point<dim,Number>::operator / (const OtherNumber factor) const -{ - Point<dim,Number> tmp = *this; - tmp /= factor; - return tmp; -} - - - template <int dim, typename Number> template <class Archive> inline @@ -485,13 +489,11 @@ Point<dim,Number>::serialize(Archive &ar, const unsigned int) * @relates Point * @relates EnableIfScalar */ -template <int dim, - typename Number, - typename OtherNumber, - typename = typename EnableIfScalar<OtherNumber>::type> +template <int dim, typename Number, typename OtherNumber> inline -Point<dim,Number> operator * (const OtherNumber factor, - const Point<dim,Number> &p) +Point<dim,typename ProductType<Number, typename EnableIfScalar<OtherNumber>::type>::type> +operator * (const OtherNumber factor, + const Point<dim,Number> &p) { return p * factor; } -- 2.39.5