-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastio_ext.h
50 lines (44 loc) · 1.33 KB
/
fastio_ext.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "fastio.h"
#include <array>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
namespace IOfast {
template <class T> Ofast &print_iters(Ofast &out, T begin, T end) noexcept {
out << '{';
while (begin != end) {
out << *begin;
begin++;
if (begin != end)
out << ", ";
else
out << '}';
}
return out;
}
template <class T, class A> Ofast &operator<<(Ofast &out, std::vector<T, A> const &v) noexcept {
out << "std::vector";
print_iters(out, v.begin(), v.end());
return out;
}
template <class T, size_t N> Ofast &operator<<(Ofast &out, std::array<T, N> const &a) noexcept {
out << "std::array";
print_iters(out, a.begin(), a.end());
return out;
}
template <class T, class C, class A> Ofast &operator<<(Ofast &out, std::set<T, C, A> const &s) noexcept {
out << "std::set";
print_iters(out, s.begin(), s.end());
return out;
}
template <class T1, class T2> Ofast &operator<<(Ofast &out, std::pair<T1, T2> const &p) noexcept {
return out << "std::pair{" << p.first << ", " << p.second < '}';
}
template <class... T> Ofast &operator<<(Ofast &out, std::tuple<T...> const &t) noexcept {
out << "std::tuple{";
size_t n = 0;
std::apply([&out, &n](auto const &... args) { ((out << args << (++n != sizeof...(T) ? ", " : "")), ...); }, t);
return out << '}';
}
} // namespace IOfast