-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIO.h
More file actions
33 lines (21 loc) · 656 Bytes
/
IO.h
File metadata and controls
33 lines (21 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include "List.h"
#include <iostream>
#include <iterator>
namespace pure {
namespace io {
template< class X, class Stream > struct Contents {
// GCC seems to have not implemented a movable io stream yet, so we'll just
// use a reference for now.
Stream& stream;
using iterator = std::istream_iterator<X>;
Contents( Stream& s ) : stream(s) { }
iterator begin() const { return iterator(stream); }
iterator end() const { return iterator(); }
};
template< class X, class Stream, class C = Contents<X,Stream> >
C fileContents( Stream& s ) {
return C( s );
}
} // namespace io
} // namespace pure