我正在阅读这本名为加速 C++ 的书。对于下面显示的“复制”
// error - no element at ret.end()
copy(bottom.begin(), bottom.end(), ret.end());
书中提到,使用 ret.end() 作为第三个参数并不是绝对正确的。但是 ret.end() 会返回一个迭代器,用于 'ret' 容器的最后一个元素。有什么问题这个论点?他们建议改用'back_inserter(ret)'。为什么会这样?
我正在阅读这本名为加速 C++ 的书。对于下面显示的“复制”
// error - no element at ret.end()
copy(bottom.begin(), bottom.end(), ret.end());
书中提到,使用 ret.end() 作为第三个参数并不是绝对正确的。但是 ret.end() 会返回一个迭代器,用于 'ret' 容器的最后一个元素。有什么问题这个论点?他们建议改用'back_inserter(ret)'。为什么会这样?