Changeset View
Changeset View
Standalone View
Standalone View
3rdparty/mockitopp/detail/util/pointers.hpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 76 | { | |||
---|---|---|---|---|---|
77 | T* _raw_ptr; | 77 | T* _raw_ptr; | ||
78 | size_t _count; | 78 | size_t _count; | ||
79 | 79 | | |||
80 | shared_ptr_impl(T* raw_ptr = 0, size_t count = 0) | 80 | shared_ptr_impl(T* raw_ptr = 0, size_t count = 0) | ||
81 | : _raw_ptr(raw_ptr) | 81 | : _raw_ptr(raw_ptr) | ||
82 | , _count(count) | 82 | , _count(count) | ||
83 | {} | 83 | {} | ||
84 | 84 | | |||
85 | shared_ptr_impl(const shared_ptr_impl &other) | ||||
86 | : _raw_ptr(other._raw_ptr) | ||||
87 | , _count(other._count) | ||||
88 | {} | ||||
89 | | ||||
85 | ~shared_ptr_impl() | 90 | ~shared_ptr_impl() | ||
86 | { D()(_raw_ptr); } | 91 | { D()(_raw_ptr); } | ||
92 | | ||||
93 | shared_ptr_impl &operator=(const shared_ptr_impl &other) | ||||
94 | { | ||||
95 | shared_ptr_impl tmp(other); | ||||
96 | std::swap(*this, other); | ||||
97 | return *this; | ||||
98 | } | ||||
99 | | ||||
87 | }* _ptr_impl; | 100 | }* _ptr_impl; | ||
88 | 101 | | |||
89 | void __decrement() | 102 | void __decrement() | ||
90 | { | 103 | { | ||
91 | if(_ptr_impl && --(_ptr_impl->_count) == 0) | 104 | if(_ptr_impl && --(_ptr_impl->_count) == 0) | ||
92 | { delete _ptr_impl; } | 105 | { delete _ptr_impl; } | ||
93 | } | 106 | } | ||
94 | 107 | | |||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |