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

iterator.h 里面重载运算符> #83

Closed
northernboyzhang opened this issue Jun 15, 2021 · 1 comment
Closed

iterator.h 里面重载运算符> #83

northernboyzhang opened this issue Jun 15, 2021 · 1 comment

Comments

@northernboyzhang
Copy link

iterator.h里面重载运算符是不是有问题呀

template <class Iterator>
bool operator>(const reverse_iterator<Iterator>& lhs,
               const reverse_iterator<Iterator>& rhs)
{
  return rhs < lhs; // 这个难道不应该是 !(rhs < lhs); 吗
}
@Alinshans
Copy link
Owner

不是呀,如果是!(rhs < lhs),那如果他们相等 不就返回true了,可以参考标准文档:https://eel.is/c++draft/reverse.iter.cmp ,我的实现不完全跟他一致,效果应该是一样

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