What about Expression:invalid comarator?
This article is to share with you what to do with Expression:invalid comarator. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Scene
The functions are defined as follows:
Template struct greaterkey {/ / is used to specify sorting and decreasing in map, and increment by default in map
Bool operator () (const T & x, const T & y) const
{
Return x > y
}
}
Template struct lesskey {
Bool operator () (const T & x, const T & y) const
{
Return x < y
}
}
Solve
After vs2010, there is a strict comparison. If the two elements are equal, be sure to return false. You can see the source code of STL:
[cpp]
Template inline
Bool _ Debug_lt_pred (_ Pr _ Pred
_ Ty1& _ Left, _ Ty2& _ Right
_ Dbfile_t _ File, _ Dbline_t _ Line)
{/ / test if _ Pred (_ Left, _ Right) and _ Pred is strict weak ordering
If (! _ Pred (_ Left, _ Right))
Return (false)
Else if (_ Pred (_ Right, _ Left))
_ DEBUG_ERROR2 ("invalid operator