C++ Library Extensions 2022.12.09
To help learn modern C++ programming
29-map_of_tuples.cpp
Go to the documentation of this file.
1#include <tpf_output.hpp>
2
5
6namespace types = tpf::types;
7
9{
10 using key_type = const char*;
11 using age_t = int;
12 using weight_t = double;
13 using name_t = std::string;
14
16 using tuple_t = typename map_t::tuple_type;
17
18 map_t info;
19
20 info["programmer"] = std::make_tuple("Thomas Kim", 20, 56.7);
21 info["president"] = std::make_tuple("Moon Jae In", 65, 56.7);
22 info["actress"] = std::make_tuple("Sophie Turner", 20, 56.7);
23
24 stream << info << endl;
25 stream << types::reverse(info) << endl;
26
27 for(auto& p: types::reverse(info))
28 {
29 auto& [key, value] = p;
30 auto& [name, age, weight] = value;
31
32 stream <<key <<": " << name <<", " << age<<", "<<weight<< endl;
33 }
34}
35
37{
38 int array[] {1, 2, 3, 4, 5};
39
40 auto msg = "I love it";
41
42 stream << msg << endl;
43
44 stream << array << endl;
45
46 stream << tpf::reverse(array) << endl;
47}
48
49int main()
50{
51 // test_map_of_tuples();
52
54}
tpf::sstream stream
void test_reverse_array()
auto endl
void test_map_of_tuples()
int main()
constexpr auto reverse(sequence< ms... > mm, sequence< rs... >)
Definition: cpg_types.hpp:4248
constexpr auto make_tuple(ArgTypes &&... args) noexcept
Definition: cpg_types.hpp:2704
Type to string name conversions are defined.
Definition: 31-visit.cpp:7
hidden::map_of_tuples_t< KeyType, ElementTypes... > map_of_tuples_t
Definition: tpf_types.hpp:7013
decltype(auto) reverse(ContainerType &&container)
Definition: tpf_types.hpp:7959
constexpr auto endl
Definition: tpf_output.hpp:973
Stream output operators << are implemented.