I guess another question would be how to do this with lines. I'm not sure, because istream_iterator doesn't let you specify a delimiter, so I guess one could try with a wrapper around a string that represents a line.
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
class Line
{
std::string content;
friend std::istream& operator >> (std::istream& is, Line& line)
{
std::getline(is, line.content);
return is;
}
friend std::ostream& operator << (std::ostream& os, const Line& line)
{
return os << line.content;
}
};
int main()
{
std::ifstream fin(__FILE__);
std::vector<Line> vec;
std::copy(std::istream_iterator<Line>(fin), std::istream_iterator<Line>(), std::back_inserter(vec));
std::copy(vec.begin(), vec.end(), std::ostream_iterator<Line>(std::cout, "\n"));
}