宇宙飞船操作员是否有 std::less/std::greater ?

rub*_*nvb 20 c++ comparison-operators spaceship-operator c++20

所有基本比较(<, <=, ==, !=, >=, >)都有一个关联的函数对象(std::less, std::less_equal, std::equal_to, std::not_equal_to, std::greater_equal, std::greater)。

飞船操作员<=>有类似的函数对象吗?如果没有,为什么没有将其添加到标准库中?

Yks*_*nen 21

std::compare_three_way 是用于三路比较的函数对象(又名宇宙飞船运算符)。

  • @rubenvb [现在](https://en.cppreference.com/w/cpp/utility/functioning) (7认同)
  • @rubenvb cppref 是一项协作努力。您可以[编辑](https://en.cppreference.com/mwiki/index.php?title=cpp/utility/compare/compare_ Three_way&amp;action=edit)它 (2认同)