]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Remove a potential problem with declaring sqr() in global scope in a header file.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 29 Jul 2004 15:54:29 +0000 (15:54 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 29 Jul 2004 15:54:29 +0000 (15:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@9536 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/vector.templates.h

index 460f8577eb72c3cecb4ef9d44df19db436bb17ab..e6cc0c818041a6df2f73a4a7f9ee91ee06695ea9 100644 (file)
   additional accuracy when using long doubles.
  */
 
-template <typename Number>
-static inline Number sqr (const Number x)
+namespace internal
 {
-  return x*x;
+  namespace VectorHelper
+  {
+    template <typename Number>
+    static inline Number sqr (const Number x)
+    {
+      return x*x;
+    }
+  }
 }
 
 
 
+
 template <typename Number>
 Vector<Number>::Vector (const Vector<Number>& v)
                 :
@@ -237,14 +244,14 @@ Number Vector<Number>::norm_sqr () const
                 eptr = ptr + (dim/4)*4;
   while (ptr!=eptr)
     {
-      sum0 += ::sqr(*ptr++);
-      sum1 += ::sqr(*ptr++);
-      sum2 += ::sqr(*ptr++);
-      sum3 += ::sqr(*ptr++);
+      sum0 += internal::VectorHelper::sqr(*ptr++);
+      sum1 += internal::VectorHelper::sqr(*ptr++);
+      sum2 += internal::VectorHelper::sqr(*ptr++);
+      sum3 += internal::VectorHelper::sqr(*ptr++);
     };
                                   // add up remaining elements
   while (ptr != end())
-    sum0 += ::sqr(*ptr++);
+    sum0 += internal::VectorHelper::sqr(*ptr++);
   
   return sum0+sum1+sum2+sum3;
 }

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.