N
NPC
Hi,
Is there any way to use an istream_iterator<> in a way which inserts each
element at the end of a newline character rather than a space character?
Could be it looks for any type of whitespace - not sure about that.
In particular, it would be nice to use it in a way which is similar to an
ostream_iterator:
std::vector<std::string> myVec;
/* add stuff to myVec */
/* add newline at the end of each element sent to cout */
std::copy(myVec.begin(), myVec.end(),
std:stream_iterator<std::string>(std::cout, "\n"));
// wish I could....
myVec.clear();
std::istream_iterator<std::string> myFile("ok.txt", /* cannot do this */,
"\n");
std::istream_iterator<std::string> eof;
std::copy(myFile, eof, std::back_inserter(myVec));
Anyway to get the same affect using an istream_iterator? Perhaps through a
traits class? Not interested in a "getline" solution here --> specifically
looking to use istream_iterator.
Thanks,
NPC
Is there any way to use an istream_iterator<> in a way which inserts each
element at the end of a newline character rather than a space character?
Could be it looks for any type of whitespace - not sure about that.
In particular, it would be nice to use it in a way which is similar to an
ostream_iterator:
std::vector<std::string> myVec;
/* add stuff to myVec */
/* add newline at the end of each element sent to cout */
std::copy(myVec.begin(), myVec.end(),
std:stream_iterator<std::string>(std::cout, "\n"));
// wish I could....
myVec.clear();
std::istream_iterator<std::string> myFile("ok.txt", /* cannot do this */,
"\n");
std::istream_iterator<std::string> eof;
std::copy(myFile, eof, std::back_inserter(myVec));
Anyway to get the same affect using an istream_iterator? Perhaps through a
traits class? Not interested in a "getline" solution here --> specifically
looking to use istream_iterator.
Thanks,
NPC