]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Avoid C++11 features
authorMatthias Maier <tamiko@43-1.org>
Thu, 3 Sep 2015 05:54:41 +0000 (07:54 +0200)
committerMatthias Maier <tamiko@43-1.org>
Mon, 7 Sep 2015 18:36:22 +0000 (13:36 -0500)
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

index a51b5678a3a2bfe40d4bf38b4d78e5cb1865fbf3..723a339a8e52f9623252343617a2d80c3f1f4134 100644 (file)
@@ -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;
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.