-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cc
50 lines (39 loc) · 870 Bytes
/
main.cc
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 <cstdlib>
#include <random>
#include <limits>
#include <iostream>
#include <map>
struct ID {
int no;
};
namespace std {
template <>
struct hash<ID> {
std::size_t operator()(ID const& id) const {
return id.no;
}
};
template <>
struct less<ID> {
bool operator() (ID const& lhs, ID const& rhs) const {
return lhs.no < rhs.no;
}
};
} // namespace std
using InnerMap = std::map<ID, ID>;
using OuterMap = std::map<std::wstring, InnerMap>;
int main() {
OuterMap om;
{
ID id1 { .no = 0 };
ID id2 { .no = 1 };
om[L"bar"][id1] = id2;
}
for (auto const & [ str, im ] : om) {
std::wcout << str << ":" << std::endl;
for (auto const & [ id1, id2 ] : im) {
std::wcout << "\t" << id1.no << ": " << id2.no << std::endl;
}
}
return EXIT_SUCCESS;
}