-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathio.cpp
66 lines (53 loc) · 1.58 KB
/
io.cpp
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
#include "sugarpp/io/io.hpp"
#include <array>
#include <iostream>
#include <tuple>
#include <vector>
using namespace SugarPP;
static void printSeparator()
{
std::cout << "----------------------------------";
}
template<typename Type>
void printResult(Type result)
{
std::cout << "You entered: " << result << '\n';
}
template<typename Type>
void test()
{
const auto value = input<Type>(std::string{ "Enter a " } + typeid(Type).name() + ": ");
printResult<Type>(value);
}
int main()
{
//test<int>();
//test<unsigned>();
//test<char>();
//test<double>();
//test<float>();
//test<std::string>();
//test<long long>();
//test<unsigned long long>();
print("Hello, what's your name?");
const auto name = input<std::string>("Enter your name: ");
print("Hello,", name, "How old are you?");
const auto age = input<int>("Enter your age: ");
print("Thanks you,", name, "who is", age, "years old");
/*print any iterable*/
std::array arr{ 1,2,3 };
print(arr);
/*print a tuple*/
std::tuple t{ "SugarPP", 123, 45.6f };
print(t);
/*print any nested printable*/
std::vector<std::vector<int>> v1{ {1,2,3}, {5,6,7,8}, {9,10} };
std::vector<std::vector<std::vector<int>>> v2{ {{1,2,3}, {5,6,7,8}, {9,10}}, {{10,11},{12,13}, {}} };
printLn(v1, v2);
/*print a bool*/
print(0.1 + 0.2 == 0.3);
/*read a file as string and print the string*/
print(file_to_string( "../../../source/io./io.cpp"));
/*read a file as vector<char> and print the vector*/
print(file_to_vec("../../../source/io./io.cpp"));
}