-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (30 loc) · 872 Bytes
/
main.cpp
File metadata and controls
34 lines (30 loc) · 872 Bytes
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
#include "constexpr_map.hpp"
#include <iostream>
using constexpr_map::construct_const_map;
int main() {
constexpr auto init = std::to_array<std::pair<int,int>>({
{ 1,2 },
{ 3, 4 },
{ 7, 1 },
{ 10, 0 },
{ 110, 2 },
{ 32, 5},
{ 72, 36},
{ 100000, 5},
{ 100001, 6},
});
auto map = construct_const_map < init, decltype([](auto d) { return d.first; }) >();
std::cout << "map's count: " << init.size() << std::endl;
std::cout << "map's value size: " << sizeof(init[0].second) << std::endl;
std::cout << "map's size: " << sizeof(map) << std::endl;
int x{};
std::cin >> x;
auto pair = map[x];
if (pair.first == x) {
std::cout << map[x].second;
}
else {
std::cout << "The map does not contains key:" << x << std::endl;
}
return 0;
}