21

All the basic comparisons (<, <=, ==, !=, >=, >) have an associated function object (std::less, std::less_equal, std::equal_to, std::not_equal_to, std::greater_equal, std::greater).

Does the spaceship operator <=> have a similar function object? If not, why was it not added to the standard library?

rubenvb
  • 74,642
  • 33
  • 187
  • 332

1 Answers1

23

std::compare_three_way is the function object for three-way comparison (aka. spaceship operator).

Yksisarvinen
  • 18,008
  • 2
  • 24
  • 52
  • Hmm seems some links are missing on cppreference to make this easily findable without already knowing its name. – rubenvb Sep 21 '20 at 11:08
  • 2
    @rubenvb cppref is a collaborative effort. You can [edit](https://en.cppreference.com/mwiki/index.php?title=cpp/utility/compare/compare_three_way&action=edit) it – 463035818_is_not_an_ai Sep 21 '20 at 11:12
  • 7
    @rubenvb it [does now](https://en.cppreference.com/w/cpp/utility/functional) – Caleth Sep 21 '20 at 11:53