-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path_test_call_by_value_container.cpp
More file actions
79 lines (62 loc) · 1.13 KB
/
_test_call_by_value_container.cpp
File metadata and controls
79 lines (62 loc) · 1.13 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* @file _test_call_by_value_container.cpp
* @brief
*
* @author Yonhgwhan, Roh (somma@somma.kr)
* @date 2019/09/12 13:51 created.
* @copyright All rights reserved by Yonghwan, Roh.
**/
#include "stdafx.h"
#include <vector>
class Widget
{
public:
Widget(int val) : _val(val)
{
log_info "constructor, val=%u", _val log_end;
}
Widget(Widget const& other): _val(other._val)
{
log_info "copy constructor, val=%u", _val log_end;
}
~Widget()
{
log_info "destructor, val=%u", _val log_end;
}
private:
uint32_t _val;
};
void func_call_by_value(std::vector<Widget> wlist)
{
for (Widget w : wlist)
{
w = w;
}
}
void func_call_by_ref(std::vector<Widget>& wlist)
{
for (Widget& w : wlist)
{
w = w;
}
}
bool test_callby_value_container()
{
_mem_check_begin
{
std::vector<Widget> wlist;
for (int i = 0; i < 4; ++i)
{
wlist.push_back(Widget(i));
}
//
log_info "=== func_call_by_value ===" log_end;
func_call_by_value(wlist);
//
log_info "=== func_call_by_ref ===" log_end;
func_call_by_ref(wlist);
log_info "=== test finished ===" log_end;
}
_mem_check_end;
return true;
}