1

std::vectorを使用してファイルからバイナリ整数を読み取るときに、イテレータを使用してコンテナを埋める方法を探していますstd::ifstream

私は次の方法を試しました:

std::vector<int> indices;
indices.reserve(index_count);
std::copy(std::istream_iterator<int>(ifstream), std::istream_iterator<int>(), std::back_inserter(indices));

ただし、エントリは追加されません。このメソッドは文字列に対してのみ機能する可能性があることを読みましたか?

とにかく、どんなアドバイスでも大歓迎です。:)

4

1 に答える 1