From 224d63be588d325298d40addb99929deffd9c6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Mon, 29 Jun 2015 13:03:48 +0200 Subject: [PATCH] On GCC 4.4 with C++0x enabled, ADL + next is unreliable This is a combination of two bugs: the call to next should pick up CGAL::next to begin with and even if it didn't iterator_traits should arguably be SFINAE friendly. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40497 We fix this by fully qualifying the call on the affected compiler. To make this work we have to partially break the dependency between CGAL/boost/graph/iterator.h and CGAL/boost/graph/graph_traits_Surface_mesh.h --- .../boost/graph/graph_traits_Surface_mesh.h | 16 +++++-- BGL/include/CGAL/boost/graph/iterator.h | 42 ++++++++++++++----- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/graph_traits_Surface_mesh.h b/BGL/include/CGAL/boost/graph/graph_traits_Surface_mesh.h index aa4e388f9b4..9d44f2987c2 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_Surface_mesh.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_Surface_mesh.h @@ -26,11 +26,21 @@ #include #include -#include +// ATTN: is included at the end of this +// file, because we need to fix some calls in that file instead of +// using ADL on broken compilers, hence those calls need to declared +// before that. #include +namespace CGAL { +template +class In_edge_iterator; +template +class Out_edge_iterator; + +} namespace boost { @@ -532,8 +542,6 @@ bool is_valid(CGAL::Surface_mesh

& sm, bool verbose = false) } // namespace CGAL - - - +#include #endif // CGAL_BOOST_GRAPH_TRAITS_SURFACE_MESH_H diff --git a/BGL/include/CGAL/boost/graph/iterator.h b/BGL/include/CGAL/boost/graph/iterator.h index 61eacb193aa..e794fcc0a66 100644 --- a/BGL/include/CGAL/boost/graph/iterator.h +++ b/BGL/include/CGAL/boost/graph/iterator.h @@ -20,8 +20,6 @@ #ifndef CGAL_BGL_ITERATORS_H #define CGAL_BGL_ITERATORS_H -#include - #include #include @@ -181,6 +179,28 @@ struct Opposite_face { return face(opposite(h,*g),*g); } }; + +// With gcc 4.4 and std=c++0x do not use ADL to find next/prev. +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40497 +template +A adl_next(A a, const Mesh& m) { +#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ == 4 && __GNUC_MINOR__ == 4 + return CGAL::next(a, m); +#else + return next(a, m); +#endif +} + +template +A adl_prev(A a, const Mesh& m) { +#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ == 4 && __GNUC_MINOR__ == 4 + return CGAL::prev(a, m); +#else + return prev(a, m); +#endif +} + + } // namespace internal /// \endcond @@ -258,7 +278,7 @@ public: } Self& operator++() { - pos = next(opposite(pos,*g),*g); + pos = internal::adl_next(opposite(pos,*g),*g); if ( pos == anchor) ++winding; return *this; @@ -271,7 +291,7 @@ public: Self& operator--() { if ( pos == anchor) --winding; - pos = opposite(prev(pos,*g),*g); + pos = opposite(internal::adl_prev(pos,*g),*g); return *this; } Self operator--(int) { @@ -358,7 +378,7 @@ public: } Self& operator++() { - pos = opposite(next(pos,*g),*g); + pos = opposite(internal::adl_next(pos,*g),*g); if ( pos == anchor) ++winding; return *this; @@ -371,7 +391,7 @@ public: Self& operator--() { if ( pos == anchor) --winding; - pos = prev(opposite(pos,*g),*g); + pos = internal::adl_prev(opposite(pos,*g),*g); return *this; } Self operator--(int) { @@ -464,7 +484,7 @@ public: if ( pos == anchor) --winding; - pos = prev(pos,*g); + pos = internal::adl_prev(pos,*g); return *this; } @@ -684,7 +704,7 @@ public: Self& operator++() { CGAL_assertion(g != NULL); - pos = opposite(next(pos,*g),*g); + pos = opposite(internal::adl_next(pos,*g),*g); return *this; } @@ -699,7 +719,7 @@ public: Self& operator--() { CGAL_assertion(g != NULL); - pos = prev(opposite(pos,*g),*g); + pos = internal::adl_prev(opposite(pos,*g),*g); return *this; } @@ -779,7 +799,7 @@ public: Self& operator++() { CGAL_assertion(g != NULL); - pos = next(pos,*g); + pos = internal::adl_next(pos,*g); return *this; } @@ -794,7 +814,7 @@ public: Self& operator--() { CGAL_assertion(g != NULL); - pos = prev(pos,*g); + pos = internal::adl_prev(pos,*g); return *this; }