I'm using Visual Studio 2013 and wizard created Win32 Console Application project. This code:
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
using namespace std;
using namespace boost::geometry;
int main()
{
model::d2::point_xy<int> p1(1, 1), p2(2, 2);
cout << "Distance p1-p2 is: " << distance(p1, p2) << endl;
return 0;
}
produces a long template barf starting with:
error C2039: 'iterator_category' : is not a member of 'boost::geometry::model::d2::point_xy<int,boost::geometry::cs::cartesian>'
The same code runs fine with gcc and clang. Do I have to change my project settings to make it compile?
EDIT
This code works fine with Visual Studio 2015 CTP, so the problem is a deficiency of overload resolution in VS2013 as Marc Glisse pointed out.
using namespace std
is not a root of the problem here as juanchopanza claims. Considering it a bad practice is somewhat arbitrary, as there are many arguments to the contrary (see discussion at Why is “using namespace std;” considered bad practice?). In this specific case, one can argue that using namespace boost::geometry
is a bad practice, not using namespace std
.
The quest of some editors to remove all redundancy from stackoverflow questions will make search more difficult, due to chicken and egg paradox: one would have to know an answer to the question before embarking on a successful search. Ultimately you could reduce the entirety of stackoverflow to 42, but utility would suffer.