C++ Library Extensions 2022.12.09
To help learn modern C++ programming
050-reverse.cpp
Go to the documentation of this file.
1#include <tpf_output.hpp>
2#include <iostream>
3#include <iterator>
4#include <variant>
5#include <vector>
6#include <initializer_list>
7#include <type_traits>
8
11
13{
14 auto v = tpf::make_vector("James", "Thomas Kim", "You");
15
16 stream << v << endl;
17}
18
20{
21 auto v = tpf::make_container(5, 7.0f, "James", "Thomas Kim", "You");
22
23 stream << "Type: " << Tpf_GetTypeCategory(v) << " \n" << v << endl;
24}
25
27{
28 auto v = tpf::make_variants(2, 4.0f, "I love it");
29
30 stream << v << endl;
31}
32
34{
35 int a = 5;
36 int f = 4.6f;
37
38 auto v = tpf::make_vector(3, a, 5, f, 7.0f);
39
40 for(auto& e: tpf::reverse(v))
41 {
42 ++e;
43
44 std::cout << e << ", ";
45 }
46
47 auto rv = tpf::reverse(v).clone();
48
50
51 stream << rv << endl;
52
53
54 //std::cout << rv << std::endl;
55}
56
58{
59 using tuple_t = std::tuple<int, const char*>;
60
61 tuple_t tuple{5, "i love it"};
62
63 stream << tuple << endl;
64}
65
67{
68 auto c1 = tpf::make_container(4, 5, 6.0f, 4.5);
69
70 stream << "c1 - " << Tpf_GetTypeCategory(c1) << endl;
71 stream << "\t" << c1 << endl;
72
73 auto c2 = tpf::make_container("James", "Sophia Kim", 4, 6.0f, 4.5);
74
75 stream << "c2 - " << Tpf_GetTypeCategory(c2) << endl;
76 stream << "\t" << c2 << endl;
77
78 auto c3 = tpf::make_container(5u, 6);
79
80 stream << "c3 - " << Tpf_GetTypeCategory(c3) << endl;
81 stream << "\t" << c3 << endl;
82
83}
84int main()
85{
86 // test_make_vector();
87
88 // test_make_container();
89
90 // test_make_variants();
91
92 // test_reverse();
93
94 // test_make_tuple();
95
97
98}
auto & cout
void test_make_vector()
Definition: 050-reverse.cpp:12
void test_make_variants()
Definition: 050-reverse.cpp:26
tpf::sstream stream
Definition: 050-reverse.cpp:9
void test_make_container()
Definition: 050-reverse.cpp:19
void test_reverse()
Definition: 050-reverse.cpp:33
void test_make_smart_container()
Definition: 050-reverse.cpp:66
auto endl
Definition: 050-reverse.cpp:10
void test_make_tuple()
Definition: 050-reverse.cpp:57
int main()
Definition: 050-reverse.cpp:84
decltype(auto) make_container(Type &&arg, Types &&... args)
Definition: tpf_types.hpp:7923
decltype(auto) reverse(ContainerType &&container)
Definition: tpf_types.hpp:7959
decltype(auto) make_vector(Type &&arg, Types &&... args)
Definition: tpf_types.hpp:7911
constexpr auto endl
Definition: tpf_output.hpp:973
decltype(auto) make_variants(Type &&arg, Types &&... args)
Definition: tpf_types.hpp:7951
Stream output operators << are implemented.
#define Tpf_GetTypeCategory(instance_arg)
A macro that returns instance_arg's type category string name.
Definition: tpf_types.hpp:1428