@@ -86,9 +86,9 @@ namespace Sass {
86
86
87
87
88
88
class SharedPtr {
89
- private :
89
+ protected :
90
90
SharedObj* node;
91
- private :
91
+ protected :
92
92
void decRefCount ();
93
93
void incRefCount ();
94
94
public:
@@ -97,16 +97,16 @@ namespace Sass {
97
97
: node(NULL ) {};
98
98
// the create constructor
99
99
SharedPtr (SharedObj* ptr);
100
- // copy assignment operator
101
- SharedPtr& operator =(const SharedPtr& rhs);
102
- // move assignment operator
103
- /* SharedPtr& operator=(SharedPtr&& rhs); */
104
100
// the copy constructor
105
101
SharedPtr (const SharedPtr& obj);
106
102
// the move constructor
107
- /* SharedPtr(SharedPtr&& obj); */
108
- // destructor
109
- ~SharedPtr ();
103
+ SharedPtr (SharedPtr&& obj);
104
+ // copy assignment operator
105
+ SharedPtr& operator =(const SharedPtr& obj);
106
+ // move assignment operator
107
+ SharedPtr& operator =(SharedPtr&& obj);
108
+ // pure virtual destructor
109
+ virtual ~SharedPtr () = 0 ;
110
110
public:
111
111
SharedObj* obj () const {
112
112
return node;
@@ -146,6 +146,29 @@ namespace Sass {
146
146
: SharedPtr(node) {};
147
147
SharedImpl (const T& node)
148
148
: SharedPtr(node) {};
149
+ // the copy constructor
150
+ SharedImpl (const SharedImpl<T>& impl)
151
+ : SharedPtr(impl.node) {};
152
+ // the move constructor
153
+ SharedImpl (SharedImpl<T>&& impl)
154
+ : SharedPtr(impl.node) {};
155
+ // copy assignment operator
156
+ SharedImpl<T>& operator =(const SharedImpl<T>& rhs) {
157
+ if (node) decRefCount ();
158
+ node = rhs.node ;
159
+ incRefCount ();
160
+ return *this ;
161
+ }
162
+ // move assignment operator
163
+ SharedImpl<T>& operator =(SharedImpl<T>&& rhs) {
164
+ // don't move our self
165
+ if (this != &rhs) {
166
+ if (node) decRefCount ();
167
+ node = std::move (rhs.node );
168
+ rhs.node = NULL ;
169
+ }
170
+ return *this ;
171
+ }
149
172
~SharedImpl () {};
150
173
public:
151
174
operator T*() const {
0 commit comments