测试两个std::pair
BOOST单元测试覆盖运营商<<
BOOST_CHECK_EQUAL(std::make_pair(0.0,0.0), std::make_pair(1.0,1.0));
我重载operator<<
为std::pair
std::ostream& operator<< (std::ostream& os, const std::pair<double,double>& t)
{
return os << "(" << t.first << ", " << t.second << ")";
}
与以下错误
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::pair<_Ty1,_Ty2>' (or there is no acceptable conversion)
有什么不对?
您可能是指“过载”,而不是“覆盖”。 – Elazar
@Jesse好,我测试你的解决方案,命名空间arround,它的工作原理(但我不知道为什么) –
@Behelke:自从它工作后,我取消了我的回答。试图弄清楚究竟发生了什么。 –