From: bangerth Date: Sun, 4 Nov 2012 22:58:42 +0000 (+0000) Subject: Partial merge from the cmake branch: Avoid warnings about accesses past the end of... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c75fba1b6e19a343595e628c081f48f52a82ed42;p=dealii-svn.git Partial merge from the cmake branch: Avoid warnings about accesses past the end of an array with newer compilers. git-svn-id: https://svn.dealii.org/trunk@27358 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/dofs/dof_renumbering.cc b/deal.II/source/dofs/dof_renumbering.cc index 2a0085e850..05f978abeb 100644 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -2016,6 +2017,7 @@ namespace DoFRenumbering center(center), counter(counter) {} + /** * Comparison operator */ @@ -2023,15 +2025,42 @@ namespace DoFRenumbering bool operator () (const DHCellIterator& c1, const DHCellIterator& c2) const { - Assert (dim >= 2, - ExcMessage ("This operation only makes sense for dim>=2.")); + // dispatch to + // dimension-dependent functions + return compare (c1, c2, dealii::internal::int2type()); + } + private: + /** + * Comparison operator for dim>=2 + */ + template + bool compare (const DHCellIterator& c1, + const DHCellIterator& c2, + dealii::internal::int2type) const + { const Point v1 = c1->center() - center; const Point v2 = c2->center() - center; const double s1 = std::atan2(v1(0), v1(1)); const double s2 = std::atan2(v2(0), v2(1)); return ( counter ? (s1>s2) : (s2>s1)); } + + + /** + * Comparison operator for dim==1 + * where this function makes no sense + */ + template + bool compare (const DHCellIterator& c1, + const DHCellIterator& c2, + dealii::internal::int2type<1>) const + { + Assert (dim >= 2, + ExcMessage ("This operation only makes sense for dim>=2.")); + return false; + } + }; }