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
51
#include <iostream>
#include "ndvector.hpp"

using std::cout, std::endl;

template <
class Ch,
class Tr,
class Ct,
std::enable_if_t<std::is_same<decltype(std::declval<Ct>().begin()),
typename Ct::iterator>::value &&
std::is_same<decltype(std::declval<Ct>().end()),
typename Ct::iterator>::value> * = nullptr>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os,
const Ct &x) {
if (x.begin() == x.end()) return os << "[]";
os << '[';
for (auto it = x.begin(); it != x.end() - 1; ++it) os << *it << ", ";
return os << x.back() << ']';
}

#define OUTPUT_(x) cout << #x << ": " << x << endl

int main() {
ndvector<5, int> v(5, 4, 3, 2, 1);
OUTPUT_(v.dim());
OUTPUT_(v[0].dim());
OUTPUT_(v[0][0].dim());
OUTPUT_(v);
v.fill(114514);
OUTPUT_(v);

cout << "==========" << endl;

ndvector<5, int> v2(5, 4, 0, 2, 1);
OUTPUT_(v2.dim());
OUTPUT_(v2);
return 0;
}