-
Notifications
You must be signed in to change notification settings - Fork 1
/
Scanner.h
26 lines (26 loc) · 910 Bytes
/
Scanner.h
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
inline namespace Infinity
{
inline namespace IO
{
class Scanner
{
istream &is;
public:
Scanner(istream &is) : is(is) { is.sync_with_stdio(false); is.tie(nullptr); }
template<class T = int> T next() { T n; is >> n; return n; }
template<class T> Scanner &operator >>(T &n) { is >> n; return *this; }
} in(cin);
class Printer
{
ostream &os;
public:
Printer(ostream &os) : os(os) { os.sync_with_stdio(false); }
void println() { print('\n'); }
template<class T> void print(const T a) { os << a; }
template<class T> void println(const T a) { print(a); println(); }
template<typename T, typename... Types> void print(const T &a, const Types &...args) { print(a); print(args...); }
template<typename... types> void println(const types &...args) { print(args...); println(); }
template<class T> Printer &operator <<(const T &n) { os << n; return *this; }
} out(cout);
}
}