-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtest.cpp
More file actions
46 lines (35 loc) · 743 Bytes
/
test.cpp
File metadata and controls
46 lines (35 loc) · 743 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
struct mySmallStruct {
char data[4];
};
struct myLargeStruct {
char data[4096];
};
template <class T>
class myTemplateClass
{
public:
myTemplateClass() {}
void set(T _t) { // BAD: T can be myLargeStruct, which is large
t = _t;
}
T t;
};
template<class T>
void myTemplateFunction(myTemplateClass<T> mtc_t) // BAD: T can be myLargeStruct, which is large
{
}
void myFunction1(mySmallStruct a, myLargeStruct b) // BAD: b is large
{
myTemplateClass<mySmallStruct> mtc_a;
myTemplateClass<myLargeStruct> mtc_b;
mtc_a.set(a);
mtc_b.set(b);
myTemplateFunction(mtc_a);
myTemplateFunction(mtc_b);
}
void myFunction2(mySmallStruct *a, myLargeStruct *b) // GOOD
{
}
void myFunction3(mySmallStruct &a, myLargeStruct &b) // GOOD
{
}