c ++ set/map如何检查键的相等性?

blu*_*mmb -2 c++ dictionary stl set

c ++ set/map如何检查键的相等性?

例如在这个例子中:

struct A
{
    int id , val;

    A( int _val = 0 , int _id = 0 ) 
    { val = _val , id = _id; }

    bool friend operator < ( const A &x , const A &y )
    {
        return x.val < y.val;
    }
};
set< A > s;
Run Code Online (Sandbox Code Playgroud)

因为我们还没有编写==运算符?

And*_*sov 5

它检查 if (!(x < y) && !(y < x))