小于操作符重载

The less-than comparison operator (operator<) is important to Standard Template Library operations such as sorting. We recommend that you implement operator< if you develop a Windows Runtime component that you intend to be used in a Standard Template Library comparison operation.

小于比较操作符对于标准库来说是比较重要的,如排序。如果你开发一个windows Runtime component,并且你准备使用标准库中的小于比较操作,建议你重载小于操作符。

The details about how to implement the less-than operator depend on your Windows Runtime component. However, here are two guidelines to consider:

关于如何实现小于比较操作符的细节,依赖于你的windows runtime component。然后下面两条建议必须考虑:

1.If you compare two reference class objects, first test whether one or both comparands is equal to nullptr; that is, test whether the comparands are valid references. If one or both comparands are invalid, return an appropriate value.

如果你比较两个引用类的对象,首先需要检查一个或者两个比较对象是否为nullPtr,即比较对象合法性判断。如果一个或者两个为非法的,返回一个合适的值。

2.If both comparands are valid, return the results of a comparison that is a strict weak ordering of the types of your comparands. For more information about strict weak ordering, see Algorithms.

如果两个比较对象都是合法的,则返回一个比较严格的弱序比较对象。具体关于严格弱序,请查看算法。

相关文章:

  • 2021-08-22
  • 2021-07-25
  • 2022-12-23
  • 2022-01-18
  • 2021-06-01
  • 2022-01-14
  • 2022-12-23
  • 2022-02-15
猜你喜欢
  • 2022-01-25
  • 2022-01-31
  • 2021-05-29
  • 2022-12-23
  • 2022-03-03
  • 2021-09-04
  • 2022-12-23
相关资源
相似解决方案