Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(讨论/勘误) p63 C++ <=> 与 Rust 的 PartialOrd trait 比较 #49

Open
mokurin000 opened this issue May 30, 2021 · 1 comment
Open

Comments

@mokurin000
Copy link
Contributor

mokurin000 commented May 30, 2021

三路运算符
https://en.cppreference.com/w/cpp/language/operator_comparison#Three-way_comparison

PartialOrd
https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html

从返回值的角度应该是Ord更类似
而且Rust写明了需要传递性……
再者 std::strong_ordering 和 std::weak_ordering 要求 a < b, a > b, a = b 恰有一个为true,而他们是 <=> 返回值

@F001
Copy link
Owner

F001 commented May 31, 2021

看起来三路运算符并不能严格对应 Ord 或者 PartialOrd,或者说既可能对应 Ord 也可能对应 PartialOrd,取决于定义这个函数的时候的返回类型。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants