有没有人在提升中看到此错误?
我正在使用CentOS 7上的GCC 7.1升级1.62编译我的项目,我的编译错误低于
它是一个助推器还是别的东西?
谢谢
boost/boost-1.62.0/include/boost/random/detail/polynomial.hpp: In member function ‘void boost::random::detail::polynomial::normalize()’:
boost/boost-1.62.0/include/boost/random/detail/polynomial.hpp:352:45: error: ambiguous overload for ‘operator==’ (operand types are ‘boost::random::detail::polynomial::reference’ and ‘int’)
while(size() && (*this)[size() - 1] == 0)
~~~~~~~~~~~~~~~~~~~~^~~~
boost/boost-1.62.0/include/boost/random/detail/polynomial.hpp:352:45: note: candidate: operator==(int, int) <built-in>
xxx.h:393:17: note: candidate: bool operator==(const bool&, const CPolyVal&)
STR_INLINE bool operator==(const TYPE& val, const CPolyVal& cpv)\
^
xxx.h:400:1: note: in expansion of macro ‘IMPLEMENT_RHS_COMPARE_TO’
IMPLEMENT_RHS_COMPARE_TO(bool)
^~~~~~~~~~~~~~~~~~~~~~~~
xxx.h:393:17: note: candidate: bool operator==(const char&, const CPolyVal&)
STR_INLINE bool operator==(const TYPE& val, const CPolyVal& cpv)\
^
xxx.h:401:1: note: in expansion of macro ‘IMPLEMENT_RHS_COMPARE_TO’
IMPLEMENT_RHS_COMPARE_TO(char)
^~~~~~~~~~~~~~~~~~~~~~~~
更像这样。
更新了错误日志。
在我们的代码库中的某个地方。
#define IMPLEMENT_RHS_COMPARE_TO(TYPE)\
STR_INLINE bool operator==(const TYPE& val, const CPolyVal& cpv)\
{\
TYPE cpv_equiv_val;\
return cpv.ConvertTo(cpv_equiv_val) == val;\
}\
// end macro
IMPLEMENT_RHS_COMPARE_TO(bool)
IMPLEMENT_RHS_COMPARE_TO(char)
IMPLEMENT_RHS_COMPARE_TO(Int8)
IMPLEMENT_RHS_COMPARE_TO(Int16)
IMPLEMENT_RHS_COMPARE_TO(Int32)
IMPLEMENT_RHS_COMPARE_TO(Int64)
IMPLEMENT_RHS_COMPARE_TO(UInt8)
IMPLEMENT_RHS_COMPARE_TO(UInt16)
IMPLEMENT_RHS_COMPARE_TO(UInt32)
IMPLEMENT_RHS_COMPARE_TO(UInt64)
IMPLEMENT_RHS_COMPARE_TO(Float32)
IMPLEMENT_RHS_COMPARE_TO(Float64)
IMPLEMENT_RHS_COMPARE_TO(std::string)
答案 0 :(得分:1)
根据您在评论中发布的内容判断,您以某种方式设法声明了一些侵入性和过度宽泛的重载==
运算符(模板?),它与Boost作者想要的比较函数竞争。在这种情况下,Boosts打算让左侧的boost::random::detail::polynomial::reference
由用户定义的转换运算符隐式转换为bool
,而右侧的0
应解释为false
。因此,目的是使用内置的int
与int
比较来比较两个bool
值。
您的运算符==
声明在此时显然对Boost代码可见,并产生歧义。例如。类似的事情发生了
// Very loose and broad template comparison operator gets declared above
// It can compare anything to `bool`
template <typename T> bool operator ==(T lhs, bool rhs)
{
return false;
}
// Unsuspecting code begins here
// It assumes that `S` vs. `int` comparisons will be interpreted as
// built-in `bool` vs. `bool` comparisons
struct S
{
operator bool() const { return false; }
void normalize()
{
S s;
s == 0; // Error: ambiguous comparison
}
};