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
// insert_dispatch 函数 template template void deque:: insert_dispatch(iterator position, IIter first, IIter last, input_iterator_tag) { if (last <= first) return; const size_type n = mystl::distance(first, last); const size_type elems_before = position - begin_; if (elems_before < (size() / 2)) { require_capacity(n, true); } else { require_capacity(n, false); } position = begin_ + elems_before; auto cur = --last; for (size_type i = 0; i < n; ++i, --cur) { insert(position, *cur); } }
The text was updated successfully, but these errors were encountered:
last <= first 这里开始就不对了,只有随机访问迭代才保证能这样比较。
last <= first
Sorry, something went wrong.
No branches or pull requests
// insert_dispatch 函数
template
template
void deque::
insert_dispatch(iterator position, IIter first, IIter last, input_iterator_tag)
{
if (last <= first) return;
const size_type n = mystl::distance(first, last);
const size_type elems_before = position - begin_;
if (elems_before < (size() / 2))
{
require_capacity(n, true);
}
else
{
require_capacity(n, false);
}
position = begin_ + elems_before;
auto cur = --last;
for (size_type i = 0; i < n; ++i, --cur)
{
insert(position, *cur);
}
}
The text was updated successfully, but these errors were encountered: