I\'m trying to code opposite action to this:
std::ostream outs; // properly initialized of course
std::set my_set; // ditto
outs << my_set.
(Edited: I should have read the question closer...)
While somewhat suspect, you can get approximately the right behavior by having an entry in the file that will "fail" the first loop, then clear the fail bit on the stream and start reading more.
Data, without an explicit size, but like this
1 1 2 3 5 8 Fibb
Fed to the code below seems to do what I meant, at least on VS2005 with STLPort.
typedef std::istream_iterator < int, char, std::char_traits ,ptrdiff_t> is_iter; std::copy( is_iter(cin), is_iter(), inserter(my_set,my_set.end())); cin.clear(); std::cin >> instr;