From f37de76f2285cccd04ef98fbf50ded2596c40bed Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 4 Nov 2012 22:58:42 +0000 Subject: [PATCH] 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 --- deal.II/source/dofs/dof_renumbering.cc | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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; + } + }; } -- 2.39.5