Subject: CGAL users discussion list
List archive
- From: Roger House <>
- To: CGAL discussion <>
- Subject: [cgal-discuss] iterator_distance won't compile
- Date: Thu, 25 Sep 2008 10:23:03 -0700
I have not been able to get this expression to compile with MSVC++
iterator_distance(P.edges_begin(), I)
where both operands are of type Polygon_2::Edge_const_iterator. The comment
in the code below shows the compiler error message. The attached file
contains the entire error message with all its gory details.
It seems that two iterators of the same type which point to the same object
should be acceptable to iterator_distance, but perhaps I fail to understand
something.
Any help will be appreciated.
Roger House
Software Developer
// idistbug.cpp -- Problem with the CGAL iterator_distance function
#include "CGAL\Cartesian.h"
#include "CGAL\Polygon_2.h"
#include <CGAL\Polygon_set_2.h>
#include <CGAL\circulator.h>
#include <iostream>
#include <cassert>
using namespace std;
typedef CGAL::Cartesian<double> K;
typedef K::Point_2 Point;
typedef CGAL::Polygon_2<K> Polygon_2;
int main()
{
cout << "Begin test of iterator_distance" << endl;
Point pointsP[] = {Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)};
Polygon_2 P(pointsP, pointsP+4);
Polygon_2::Edge_const_iterator I = P.edges_begin();
++I;
// The call of iterator_distance in the following statement does not compile:
// c:\hped\builds\sr\dev33x\rlocal\debug\build\include\stlport\stl\
// _iterator_base.h(372) : error C2678: binary '-' : no operator found
// which takes a left-hand operand of type
// 'const CGAL::Polygon_2_edge_iterator<Traits_,Container_>'
// (or there is no acceptable conversion)
cout << " iterator_distance = " << iterator_distance(P.edges_begin(), I) << endl;
cout << "Press any nonwhitespace key and Enter to terminate" << endl;
string c;
cin >> c;
}
// end idistbug.cpp
c:\hped\builds\sr\dev33x\rlocal\debug\build\include\stlport\stl\
_iterator_base.h(372) : error C2678: binary '-' : no operator found
which takes a left-hand operand of type
'const CGAL::Polygon_2_edge_iterator<Traits_,Container_>'
(or there is no acceptable conversion)
with
[
Traits_=K,
Container_=stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>
]
c:\users\roghouse\332\build\projects\cgal_eesof\include\cgal\polygon_2\polygon_2_edge_iterator.h(137):
could be 'CGAL::Polygon_2_edge_iterator<Traits_,Container_>
CGAL::Polygon_2_edge_iterator<Traits_,Container_>::operator -(__w64 int)'
with
[
Traits_=K,
Container_=stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>
]
c:\users\roghouse\332\build\projects\cgal_eesof\include\cgal\polygon_2\polygon_2_edge_iterator.h(143):
or '__w64 int CGAL::Polygon_2_edge_iterator<Traits_,Container_>::operator
-(const CGAL::Polygon_2_edge_iterator<Traits_,Container_> &)'
with
[
Traits_=K,
Container_=stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>
]
c:\users\roghouse\332\build\projects\cgal_eesof\include\cgal\functions_on_enums.h(41):
or 'CGAL::Sign CGAL::operator -(CGAL::Sign)' [found using argument-dependent
lookup]
while trying to match the argument list '(const
CGAL::Polygon_2_edge_iterator<Traits_,Container_>, const
CGAL::Polygon_2_edge_iterator<Traits_,Container_>)'
with
[
Traits_=K,
Container_=stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>
]
c:\hped\builds\sr\dev33x\rlocal\debug\build\include\stlport\stl\_iterator_base.h(378)
: see reference to function template instantiation '__w64 int
stlp_std::__distance<_InputIterator>(const _RandomAccessIterator &,const
_RandomAccessIterator &,const stlp_std::random_access_iterator_tag &)' being
compiled
with
[
_InputIterator=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>,
_RandomAccessIterator=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>
]
c:\users\roghouse\332\build\projects\cgal_eesof\include\cgal\circulator.h(473)
: see reference to function template instantiation '__w64 int
stlp_std::distance<I>(_InputIterator,_InputIterator)' being compiled
with
[
I=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>,
_InputIterator=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>
]
c:\users\roghouse\332\build\projects\cgal_eesof\include\cgal\circulator.h(484)
: see reference to function template instantiation '__w64 int
CGAL::I_iterator_distance<IC>(const I &,const I &,CGAL::Iterator_tag)' being
compiled
with
[
IC=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>,
I=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>
]
c:\users\roghouse\332\build\projects\eecad\cgaltest\idistbug.cpp(26)
: see reference to function template instantiation '__w64 int
CGAL::iterator_distance<CGAL::Polygon_2_edge_iterator<Traits_,Container_>>(const
IC &,const IC &)' being compiled
with
[
Traits_=K,
Container_=stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>,
IC=CGAL::Polygon_2_edge_iterator<K,stlp_std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>
]
- [cgal-discuss] iterator_distance won't compile, Roger House, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Sylvain Pion, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Roger House, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Sylvain Pion, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Roger House, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Sylvain Pion, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Roger House, 09/25/2008
- Re: [cgal-discuss] iterator_distance won't compile, Sylvain Pion, 09/25/2008
Archive powered by MHonArc 2.6.16.