File tree 1 file changed +23
-4
lines changed
patch_common/include/patch_common
1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,15 @@ class ComPtr
12
12
ComPtr (const ComPtr& other) :
13
13
m_ptr (other.m_ptr)
14
14
{
15
- if (m_ptr)
15
+ if (m_ptr) {
16
16
m_ptr->AddRef ();
17
+ }
18
+ }
19
+
20
+ ComPtr (ComPtr&& other) :
21
+ m_ptr (other.m_ptr)
22
+ {
23
+ other.m_ptr = nullptr ;
17
24
}
18
25
19
26
~ComPtr ()
@@ -23,11 +30,22 @@ class ComPtr
23
30
24
31
ComPtr& operator =(const ComPtr& other)
25
32
{
26
- if (&other != this ) {
33
+ if (&other. m_ptr != &m_ptr ) {
27
34
release ();
28
35
m_ptr = other.m_ptr ;
29
- if (m_ptr)
36
+ if (m_ptr) {
30
37
m_ptr->AddRef ();
38
+ }
39
+ }
40
+ return *this ;
41
+ }
42
+
43
+ ComPtr& operator =(ComPtr&& other)
44
+ {
45
+ if (&other.m_ptr != &m_ptr) {
46
+ release ();
47
+ m_ptr = other.m_ptr ;
48
+ other.m_ptr = nullptr ;
31
49
}
32
50
return *this ;
33
51
}
@@ -50,8 +68,9 @@ class ComPtr
50
68
51
69
void release ()
52
70
{
53
- if (m_ptr)
71
+ if (m_ptr) {
54
72
m_ptr->Release ();
73
+ }
55
74
m_ptr = nullptr ;
56
75
}
57
76
};
You can’t perform that action at this time.
0 commit comments