我有一个在Linux上运行的C++代码,但是我在Windows上得到了一个Visual C++中的错误。代码如下:Visual C++因为comperator而抛出映射异常
struct dependence {
dependence() {}
dependence(string CUid, LID sink, LID source, std::string var)
: CUid(CUid), sink(sink), source(source), var(var) {}
string CUid;
LID sink = 0;
LID source = 0;
std::string var;
};
struct dependenceCompare {
bool operator() (const dependence& lhs, const dependence& rhs) const{
return ((lhs.CUid<rhs.CUid) || (lhs.source<rhs.source) || (lhs.sink < rhs.sink) || (lhs.var < rhs.var));
}
};
在Windows上运行的代码,我得到以下错误:
Debug Assertion Failed!" c:\windows\system32\MSCP120D.dll c:\Program Files\Microsoft Visual Studio 12.0\VC\include\xtree line 1795 Expression: invalid operator< When I change the comparator to just one if clause, it works:
struct dependenceCompare {
bool operator() (const dependence& lhs, const dependence& rhs) const{
return ((lhs.CUid < rhs.CUid));
}
};
我已阅读本线,但无法找出问题的所在以及为什么它在Linux中使用cmake而不是在Visual Studio C++中。
请尝试创建一个[最小,完整,可验证的示例](HTTP: //stackoverflow.com/help/mcve)*非工作*代码。包括你如何使用你向我们展示的结构。 –
如果在所述调试断言上按_ignore_会怎么样?调试断言,不是,_technically_,错误,并且仅在调试版本中才可见。 –
这是一个调试断言,不是一个例外。它附带有趣的说明。你需要养成实际阅读错误/警告对话的习惯。 – IInspectable