4 ms·
What if you want to do an equality operation, but the greater than or less than operators require lots of computation? If an object only defines the space ship
by hak8or 7y ago
What if you want to do an equality operation, but the greater than or less than operators require lots of computation? If an object only defines the space ship operator, then isn't it very likely that you will get a lot of extra computation when all you care baout if the two objects are or aren't equal to each other?
- colejohnson66 7y agoYou can choose not to define the spaceship operator and keep using the “old” ones if you want.
- aw1621107 7y agoI believe programmers are still free to define specific operators in lieu of the compiler-derived ones for such cases. I found a blog post which raised similar concerns [0], and P1185 [1] proposes some solutions. I don't know whether they made it into the standard, though. [0]: https://foonathan.net/2018/10/spaceship-proposals/ https://foonathan.net/2018/10/spaceship-proposals/ [1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r1.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p118...
- johannes1234321 7y agoSpecialized Operators have higher priority. If available they will be called.