我正在尝试编译以下代码:
#include <boost/geometry/geometries/point_xy.hpp>
#include <iostream>
#include <utility>
typedef boost::geometry::model::d2::point_xy<long> Point;
typedef std::pair<Point, Point> Vector;
bool operator==(const Point& p1, const Point& p2) {
return p1.x() == p2.x() && p1.y() == p2.y();
}
int main() {
Vector vec1(Point(0,0), Point(1,1));
Vector vec2(Point(0,0), Point(1,2));
std::cout << ((vec1 == vec2) == false) << std::endl;
std::cout << ((vec1 == vec1) == true) << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
VS2012 C++编译器返回以下编译错误:
... VC\include\utility(219):错误C2678:二进制'==':找不到哪个运算符带有'const Point'类型的左手操作数(或者没有可接受的转换)
GCC C++编译器返回以下编译错误:
/usr/include/c++/4.8/bits/stl_pair.h:
在实例化'bool std :: operator ==(const std :: pair <_T1,_T2>&,const std :: pair <_T1,_T2>&)[with …