Created
June 30, 2016 15:16
-
-
Save Loki-Astari/ac8763f0032ad27819c0d687a6732810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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