c++ stl sort 自定义排序函数cmp要遵循 strict weak ordering

   满足strict weak ordering的运算符能够表达其他所有的逻辑运算符(logical operator):

  • <(a, b)  : (a < b)
  • <=(a, b): !(b < a)
  • ==(a, b): !(a < b) && !(b < a)
  • !=(a, b) : (a < b) || (b < a)
  • >(a, b)  : (b < a)
  • >=(a, b): !(a < b)

引用自https://www.cnblogs.com/walkerlala/p/5561339.html

当使用>=或者<=的情况可能产生RE,参见https://blog.csdn.net/tanjinjun2011/article/details/33844357 

猜你喜欢

转载自www.cnblogs.com/pengpenggege/p/10251682.html