We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在 rb_tree<T, Compare>:: find(const key_type& key) const 函数定义中: 最后一行: return ( j == end() || key_comp_(key, value_traits::get_key(*j)) ) ? end() : j; 出现报错 error: operands to ?: have different types 报错指出:end()的类型为 mystl::rb_tree_const_iterator<int> j 的类型为 mystl::rb_tree_iterator<int> 因此,此处不能使用三元表达式,只能老老实实使用 if - else
rb_tree<T, Compare>:: find(const key_type& key) const
return ( j == end() || key_comp_(key, value_traits::get_key(*j)) ) ? end() : j;
error: operands to ?: have different types
mystl::rb_tree_const_iterator<int>
mystl::rb_tree_iterator<int>
if - else
The text was updated successfully, but these errors were encountered:
实际的 bug 应该是 mystl::rb_tree_iterator<int> 不能隐式转换成 mystl::rb_tree_const_iterator<int> 和 mystl::rb_tree_const_iterator<int> 存在双向隐式转换。
应该只能从 mystl::rb_tree_iterator<int> 隐式转换成 mystl::rb_tree_const_iterator<int> 而不能反过来。
Sorry, something went wrong.
No branches or pull requests
在
rb_tree<T, Compare>:: find(const key_type& key) const
函数定义中:
最后一行:
return ( j == end() || key_comp_(key, value_traits::get_key(*j)) ) ? end() : j;
出现报错
error: operands to ?: have different types
报错指出:end()的类型为
mystl::rb_tree_const_iterator<int>
j 的类型为
mystl::rb_tree_iterator<int>
因此,此处不能使用三元表达式,只能老老实实使用
if - else
The text was updated successfully, but these errors were encountered: