ベクターデータを以下のようにコピーしようとしsample
てY
います
std::map<std::string, std::vector<double > >sample;
std::map<std::string, std::vector<double > >::iterator it1=sample.begin(), end1=sample.end();
std::vector<double> Y;
次のコードを使用しています:
while (it1 != end1) {
std::copy(it1->second.begin(), it1->second.end(), std::ostream_iterator<double>(std::cout, " "));
++it1;
}
出力は正常に出力されますが、上記の std::copy ブロックを以下に置き換えると、segfault が発生します。
while (it1 != end1) {
std::copy(it1->second.begin(), it1->second.end(), Y.end());
++it1;
}
it1->second の内容を Y にコピーしたいだけです。なぜ機能しないのですか?どうすれば修正できますか?