Skip to content

Commit e43ae29

Browse files
committed
replace auto_ptr with unique_ptr
1 parent 4011def commit e43ae29

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Support for dynamic typing in C++.
7171
int b;
7272
};
7373
74-
std::auto_ptr<TestStr> holder(new TestStr());
74+
std::unique_ptr<TestStr> holder(new TestStr());
7575
holder->a = 12;
7676
holder->b = 21;
7777

include/xnode.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class xnode_setter
191191
// accepts pointer to value, takes ownership of it
192192
static void hold_ptr(void **dest, void *src)
193193
{
194-
std::auto_ptr<T> holder(static_cast<T *>(src));
194+
std::unique_ptr<T> holder(static_cast<T *>(src));
195195
*dest = reinterpret_cast<void *>(*holder);
196196
}
197197

@@ -230,7 +230,7 @@ class xnode_setter<T, xstNull>
230230

231231
static void hold_ptr(void **dest, void *src)
232232
{
233-
std::auto_ptr<T> holder(static_cast<T *>(src));
233+
std::unique_ptr<T> holder(static_cast<T *>(src));
234234
*dest = nullptr;
235235
}
236236

@@ -269,7 +269,7 @@ class xnode_setter<T, xstCasted>
269269

270270
static void hold_ptr(void **dest, void *src)
271271
{
272-
std::auto_ptr<T> holder(static_cast<T *>(src));
272+
std::unique_ptr<T> holder(static_cast<T *>(src));
273273
T *dptr = reinterpret_cast<T *>(dest);
274274
*dptr = *holder;
275275
}
@@ -309,7 +309,7 @@ class xnode_setter<T, xstPointer>
309309

310310
static void hold_ptr(void **dest, void *src)
311311
{
312-
std::auto_ptr<T> holder(static_cast<T *>(src));
312+
std::unique_ptr<T> holder(static_cast<T *>(src));
313313
*dest = const_cast<void *>(reinterpret_cast<const void *>(*holder));
314314
}
315315

@@ -921,7 +921,7 @@ class basic_xnode
921921
template <typename T>
922922
T *release()
923923
{
924-
std::auto_ptr<T> result;
924+
std::unique_ptr<T> result;
925925

926926
if (vtable_->deleter_ != nullptr)
927927
{
@@ -941,7 +941,7 @@ class basic_xnode
941941
template <typename T>
942942
void hold(T *value)
943943
{
944-
std::auto_ptr<T> holder(value);
944+
std::unique_ptr<T> holder(value);
945945
destroy();
946946
vtable_ = xnode_get_vtable<T>();
947947
vtable_->hold_(&value_, holder.release());

test/xnode_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void TestHoldObj() {
249249
int b;
250250
};
251251

252-
std::auto_ptr<TestStr> holder(new TestStr());
252+
std::unique_ptr<TestStr> holder(new TestStr());
253253
holder->a = 12;
254254
holder->b = 21;
255255

@@ -265,7 +265,7 @@ void TestHoldObj() {
265265

266266
void TestHoldInt() {
267267

268-
std::auto_ptr<int> holder(new int);
268+
std::unique_ptr<int> holder(new int);
269269
*holder = 12;
270270

271271
xnode value;
@@ -356,7 +356,7 @@ void TestDynamicCastVptr() {
356356
virtual int getValue() { return 111; }
357357
};
358358

359-
std::auto_ptr<MyNode> value(new MyNode());
359+
std::unique_ptr<MyNode> value(new MyNode());
360360

361361
xnode wrap;
362362
wrap.hold(value.release());

0 commit comments

Comments
 (0)