Consider a CGAL::Arrangement_2
. Right now, I have to iterate through it like this:
using MyArrangement = CGAL::Arrangement_2<MyTraits, MyDcel>;
for(MyArrangement::Face_handle face = map.faces_begin(); face != map.faces_end(); ++face)
{
do_stuff(face);
}
If I try to migrate this to using a C++11-style range-based for
loop like this:
for(auto face : gMap)
{
do_stuff(face)
}
I get the following error (emphasis mine):
Error:(1385, 13) invalid range expression of type 'CGAL::Arrangement_2 > >, true>, std::__1::vector > >, true> >, std::__1::allocator > >, true> > > >, CGAL::Arr_consolidated_curve_data_traits_2 > >, true> >, int> >, CGAL::Arr_extended_dcel > >, true>, std::__1::vector > >, true> >, std::__1::allocator > >, true> > > >, CGAL::Arr_consolidated_curve_data_traits_2 > >, true> >, int> >, GIS_vertex_data, GIS_halfedge_data, GIS_face_data, CGAL::Arr_vertex_base > >, true> > >, CGAL::Gps_halfedge_base > >, true> >, CGAL::_Unique_list > >, CGAL::Gps_face_base> >'; no viable 'begin' function available
The error is the same if I change the for loop to use auto &face
or const auto &face
.
Does anyone have a workaround for this, or some nice wrapper to make it work? I'm trying to avoid having to resort to using this monstrosity with a lambda argument:
template<typename F>
void for_each_face(MyArrangement &map, F callback)
{
for(MyArrangement::Face_handle f = map.faces_begin(); f != map.faces_end(); ++f)
{
callback(f);
}
}
Aucun commentaire:
Enregistrer un commentaire