Essential C++书中,给了一段关于iosteram iterators的例程,如下所示:
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
istream_iterator< string > is( cin );
istream_iterator< string > eof;
vector< string > text;
copy( is, eof, back_inserter( text ));
sort( text.begin(), text.end() );
ostream_iterator<string> os( cout, " " );
copy( text.begin(), text.end(), os );
}
在输入的过程中,出现了一个问题,就是控制台不断要求输入,好像进入死循环,对于这个问题, http://wenku.baidu.com/view/91f2f2eff8c75fbfc77db2f5.html,给出了一些解释。