-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialization.cpp
More file actions
66 lines (55 loc) · 1.67 KB
/
Initialization.cpp
File metadata and controls
66 lines (55 loc) · 1.67 KB
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
56
57
58
59
60
61
62
63
64
65
66
/**
* \file Initialization.cpp
* \brief
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
// Initialize an unordered_map through initializer_list
const std::unordered_map<std::string, int> wordMap
(
{
{"First", 1},
{"Second", 2},
{"Third", 3}
}
);
{
std::cout << STD_TRACE_VAR(wordMap) << std::endl;
std::cout << "*******************" << std::endl;
}
{
// Initialize an unordered_map through another range of elements of type std::pair
const std::unordered_map<std::string, int> wordMap_2(wordMap.cbegin(), wordMap.cend());
std::cout << STD_TRACE_VAR(wordMap_2) << std::endl;
std::cout << "*******************" << std::endl;
}
{
// Initialize an unordered_map through other unordered_map
const std::unordered_map<std::string, int> wordMap_3(wordMap);
std::cout << STD_TRACE_VAR(wordMap_3) << std::endl;
std::cout << "*******************" << std::endl;
}
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
wordMap: std::unordered_map (size=3): {
std::pair: {Third,3}
std::pair: {Second,2}
std::pair: {First,1}}
*******************
wordMap_2: std::unordered_map (size=3): {
std::pair: {First,1}
std::pair: {Second,2}
std::pair: {Third,3}}
*******************
wordMap_3: std::unordered_map (size=3): {
std::pair: {Third,3}
std::pair: {Second,2}
std::pair: {First,1}}
*******************
#endif