Skip to content

Instantly share code, notes, and snippets.

@Loki-Astari

Loki-Astari/Test.cpp

Created Jun 30, 2016
Embed
What would you like to do?
#include <iterator>
#include <fstream>
#include <iostream>
template<typename T>
class FWrapper
{
std::ifstream& file;
public:
FWrapper(std::ifstream& file)
: file(file)
{}
std::istream_iterator<T> begin() {return std::istream_iterator<T>(file);}
std::istream_iterator<T> end() {return std::istream_iterator<T>();}
};
int main()
{
std::ifstream f("data");
FWrapper<char> file(f);
for(auto x: file)
{
std::cout << x << " ";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment