-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
58 lines (46 loc) · 871 Bytes
/
main.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
#include <iostream>
#include <string>
#include <vector>
template<typename T>
void print(T param)
{
std::cout << param << '\n';
}
template<typename T, typename ... Types>
void print(T first, Types const &... args)
{
std::cout << first << '\n';
if constexpr (sizeof...(Types) == 0)
{
return;
}
else
{
print(args...);
}
}
template<typename ... T>
void doublePrint(T const& ... args)
{
print(args + args ... );
}
template<typename ... T>
void addOne(T const&... args)
{
print((args + 1 )...);
}
// variadic indices
template<typename C, typename ... Idx>
void printElems(C const& coll, Idx... idx)
{
print(coll[idx]...);
}
int main()
{
std::string s1 = "hello";
std::string s2 = "hi";
std::string s3 = "hi threre";
addOne(10, false, 16.3, -10, 3);
std::vector<std::string> coll = {"good", "times", "say", "bye"};
printElems(coll, 2, 0, 3);
}