Extend the concept to operator-> and fix the bug in edge_circulator.

The work-around is a little fishy, because it involves storing the
segment, but so it be. The concept shouldn't check for operator->
though, it is too strict.
This commit is contained in:
Philipp Möller 2012-11-17 02:32:44 +01:00
parent 465c5b265a
commit 801721202e
2 changed files with 23 additions and 5 deletions

View File

@ -11,6 +11,16 @@
namespace CGAL { namespace Concepts {
template <typename T>
void deref(T& t) {
t.operator->();
}
template <typename T>
void deref(T*) {
// valid anyway
}
// N.B.: there is no such concept as Circulator as it is immaterial
template <typename C>
struct ForwardCirculator
@ -40,6 +50,8 @@ struct ForwardCirculator
a++;
(void)*a; // suppress unused warning, don't check the return type
// to allow for proxies
deref(a);
}
private:
C a;
@ -90,6 +102,3 @@ private:
#endif /* CGAL_CIRCULATOR_CONCEPTS_H */

View File

@ -55,6 +55,8 @@ class Polygon_2_const_edge_circulator {
private:
Vertex_const_circulator first_vertex;
// carry around the segment to be a proper iterator
Segment_2 segment;
public:
Polygon_2_const_edge_circulator() {}
@ -86,13 +88,20 @@ class Polygon_2_const_edge_circulator {
return !(first_vertex == x.first_vertex);
}
Segment_2 operator*() const
const Segment_2& operator*() const
{
Vertex_const_circulator second_vertex = first_vertex;
++second_vertex;
typename Traits::Construct_segment_2 construct_segment_2 =
Traits().construct_segment_2_object();
return construct_segment_2(*first_vertex, *second_vertex);
const_cast<Polygon_2_const_edge_circulator*>(this)->segment =
construct_segment_2(*first_vertex, *second_vertex);
return segment;
}
const Segment_2* operator->() const
{
return &(**this);
}
Polygon_2_const_edge_circulator<_Traits, _Container>& operator++()