挿入イテレータと、挿入したい要素へのイテレータがありますが、使用が許可されていませんstd::copy
。
これは、c++ リファレンス ページで見つけたものです。
std::copy (bar.begin(),bar.end(),insert_it);
これもやりたいのですが使えませんstd::copy
。別の方法はありますか?
auto first = bar.begin();
auto last = bar.end();
while (first!=last)
{
*insert_it = *first;
++insert_it;
++first;
}
あなたが提供するコードは、コンテンツを bar.begin() から bar.end() に挿入イテレータに移動します。私はあなたが使用した用語に混乱しており、insert
何std::copy
も挿入せず、コンテンツをコピーするだけです。
実際にコンテナに要素を挿入するには、これを使用できます。
your_container.insert(insert_it, bar.begin(),bar.end());
http://en.cppreference.com/w/cpp/container/vector/insert/insert/の例をここで見つけることができますstd::vector
これが役に立てば幸いです、Raxvan。