typedef struct Edge
{
int v1, v2, w;
bool operator <(const Edge &rhs) const{
bool b = v1 < rhs.v1 || v2 < rhs.v2;
return (b);
}
} edge;
template <class T>
struct my_less
{
bool operator()(const T& _Left, const T& _Right) const
{
return (_Left < _Right);
}
};
int main(int argc, char *argv[])
{
set <edge, my_less<edge> > F;
edge e3 = { 3, 3, 3};
edge e4 = { 3, 7, 3};
edge e5 = { 2, 7, 3};
F.insert(e3);
printf("e3 ? %d\n", F.find(e3)!=F.end()); // O
printf("e4 ? %d\n", F.find(e4)!=F.end()); // O
printf("e5 ? %d\n", F.find(e5)!=F.end()); // X
//printf("%d\n", e3<e4);
return 0;
}
このコードを実行すると、「F.find(e5)!=F.end()」で次のメッセージとともにエラーが発生しました。
"Debug Assertion Failed!. Expression: invalid operator < "
'(x,y), (p,q)' の 2 つのエッジが等しい条件は、
!(x < p || y < q) && !(p < x || q < y)
「(x>=p && y>=q) && (p>=x && q>=y)」のようになります
アサーションが発生した理由は本当にわかりません。
何か問題がありますか?