-
Notifications
You must be signed in to change notification settings - Fork 17
/
test_Array.cpp
55 lines (51 loc) · 1019 Bytes
/
test_Array.cpp
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
52
53
54
55
#include <array>
#include <cstdint>
#include <cstddef>
#include <cstdio>
#include <string>
#include <iostream>
#include <stdexcept>
#include <utility>
#include <vector>
#include "Array.hpp"
// concept Functor:
// Class::operator()
// void (*fp)()
// concept RandomAccessorIterator:
// *p
// p->...
// ++p
// --p
// p += n
// p -= n
// p + n
// p - n
// p[n]
// p1 - p2
// p1 != p2
// p1 < p2
template <class T, size_t N>
void iota(Array<T, N> &a) noexcept {
T count = 0;
// for (auto it = a.begin(), eit = a.end(); it != eit; ++it)
for (auto &ai: a) {
ai = count++; // a[i] = i;
}
}
int main() {
auto a = Array{2, 1, 0};
for (auto &ai: a) {
std::cout << ai << '\n';
}
iota(a);
for (auto &ai: a) {
std::cout << ai << '\n';
}
std::cout << "front:" << a.front() << '\n';
std::cout << "back:" << a.back() << '\n';
for (auto it = a.rbegin(); it != a.rend(); ++it) {
std::cout << *it << " ";
}
std::cout << '\n';
return 0;
}