-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveSemantic.cpp
More file actions
61 lines (51 loc) · 932 Bytes
/
Copy pathMoveSemantic.cpp
File metadata and controls
61 lines (51 loc) · 932 Bytes
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
#include "pch.h"
#include "TTracer.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
//bei Return erfolgt move-semantic :)
template<typename intType, int count=30>
std::vector<intType> build()
{
std::vector<intType> vals;
vals.reserve(count);
for (int i = 0; i < count; ++i)
{
vals.emplace_back(i * 5);
}
return vals;
}
template<typename intType, size_t count = 30>
std::array<intType,count> buildFix()
{
std::array<intType,count> vals;
for (int i = 0; i < count; ++i)
{
vals[i]=i*5;
}
return vals;
}
TEST(move_semantic, cout_Timing)
{
for (int i = 0; i < 30; ++i)
{
std::cout << (i * 5) << std::endl;
}
}
TEST(move_semantic, move1)
{
std::vector<TTracer> tt = build<TTracer>();
for (const auto& t : tt)
{
std::cout << t << std::endl;
}
}
TEST(move_semantic, move2)
{
auto tt = buildFix<TTracer,30>();
for (const auto& t : tt)
{
std::cout << t << std::endl;
}
}