From 7cf417b5f23f4fbaa04c739cc6f9e94cb84244bc Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 29 Jul 2004 15:54:29 +0000 Subject: [PATCH] Remove a potential problem with declaring sqr() in global scope in a header file. git-svn-id: https://svn.dealii.org/trunk@9536 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/vector.templates.h | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/deal.II/lac/include/lac/vector.templates.h b/deal.II/lac/include/lac/vector.templates.h index 460f8577eb..e6cc0c8180 100644 --- a/deal.II/lac/include/lac/vector.templates.h +++ b/deal.II/lac/include/lac/vector.templates.h @@ -36,14 +36,21 @@ additional accuracy when using long doubles. */ -template -static inline Number sqr (const Number x) +namespace internal { - return x*x; + namespace VectorHelper + { + template + static inline Number sqr (const Number x) + { + return x*x; + } + } } + template Vector::Vector (const Vector& v) : @@ -237,14 +244,14 @@ Number Vector::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; } -- 2.39.5