-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathModularizedStandardLibrary.cpp
More file actions
60 lines (47 loc) · 1.57 KB
/
ModularizedStandardLibrary.cpp
File metadata and controls
60 lines (47 loc) · 1.57 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
// =====================================================================================
// ModularizedStandardLibrary.cpp
// =====================================================================================
module modern_cpp:modularized_standard_library;
import std;
namespace ModularizedStandardLibrary {
static void test_01()
{
std::println("Hello World");
}
static void test_02()
{
std::println("List of Entries:");
std::unordered_map<std::string, std::size_t> phonebook
{
{ "Hans Meier" , 12345678 },
{ "Franz Schneider", 81726354 },
{ "Hubert Mueller", 87654321 }
};
for (const auto& [name, number] : phonebook) {
std::println("{}: {}", name, number);
}
std::vector<std::string> names;
// retrieve names from phonebook
std::transform(
phonebook.begin(),
phonebook.end(),
std::back_inserter(names),
[](const std::pair<const std::string, std::size_t>& entry) {
return std::get<0>(entry);
}
);
std::println("List of Persons:");
for (const auto& name : names) {
std::println("{}", name);
}
}
}
void main_modularized_standard_library()
{
using namespace ModularizedStandardLibrary;
test_01();
test_02();
}
// =====================================================================================
// End-of-File
// =====================================================================================