From 0fdf19714613a82a184f4f6e75fb9a4f9b62f18a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 19 Jan 2014 10:05:08 +0200 Subject: Use std::unique_ptr instead of std::auto_ptr in C++11 mode --- tests/cxx/tree/containment/driver.cxx | 45 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'tests/cxx/tree/containment/driver.cxx') diff --git a/tests/cxx/tree/containment/driver.cxx b/tests/cxx/tree/containment/driver.cxx index ac798a6..aa701ae 100644 --- a/tests/cxx/tree/containment/driver.cxx +++ b/tests/cxx/tree/containment/driver.cxx @@ -6,11 +6,18 @@ // Test tree node containment. // -#include // std::auto_ptr +#include // std::auto_ptr/unique_ptr #include #include "test.hxx" +#ifdef XSD_CXX11 +# include // std::move +# define XSD_MOVE(x) std::move(x) +#else +# define XSD_MOVE(x) x +#endif + using namespace std; using namespace test; @@ -20,11 +27,11 @@ main () // Change of a container in a sub-tree without ID. // { - auto_ptr i (new inner ()); + XSD_AUTO_PTR i (new inner ()); i->ref ("foo"); outer o; - o.i (i); + o.i (XSD_MOVE (i)); o.ref ("foo"); assert (o.i ()->ref ()->get () == 0); @@ -34,14 +41,14 @@ main () // Change of container in a sub-tree with ID inside. // { - auto_ptr i (new inner ()); + XSD_AUTO_PTR i (new inner ()); inner* p (i.get ()); i->id ("foo"); i->ref ("foo"); assert (i->ref ()->get () == p); outer o; - o.i (i); + o.i (XSD_MOVE (i)); o.ref ("foo"); assert (o.i ()->ref ()->get () == p); @@ -51,10 +58,10 @@ main () // Change of a container in ID. // { - auto_ptr id (new xml_schema::id ("foo")); + XSD_AUTO_PTR id (new xml_schema::id ("foo")); inner i; - i.id (id); + i.id (XSD_MOVE (id)); i.ref ("foo"); assert (i.ref ()->get () == &i); } @@ -62,12 +69,12 @@ main () // Change of a container in a type derived from ID with ID inside. // { - auto_ptr id (new id_ex ("foo")); + XSD_AUTO_PTR id (new id_ex ("foo")); id_ex* p (id.get ()); id->id ("bar"); inner i; - i.id_ex (id); + i.id_ex (XSD_MOVE (id)); i.ref ("foo"); assert (i.ref ()->get () == &i); @@ -81,28 +88,28 @@ main () { id i1 ("a"), i2 ("b"); - auto_ptr ic (new ids); + XSD_AUTO_PTR ic (new ids); ic->id ().push_back (i1); ic->id ().push_back (i2); - auto_ptr r1 (new xml_schema::idrefs); + XSD_AUTO_PTR r1 (new xml_schema::idrefs); r1->push_back (xml_schema::idref ("a")); r1->push_back (xml_schema::idref ("b")); - auto_ptr r2 (new idref_list); + XSD_AUTO_PTR r2 (new idref_list); r2->push_back (xml_schema::idref ("a")); r2->push_back (xml_schema::idref ("b")); - auto_ptr rc1 (new idrefs1); - auto_ptr rc2 (new idrefs2); + XSD_AUTO_PTR rc1 (new idrefs1); + XSD_AUTO_PTR rc2 (new idrefs2); - rc1->idrefs (r1); - rc2->idrefs (r2); + rc1->idrefs (XSD_MOVE (r1)); + rc2->idrefs (XSD_MOVE (r2)); model m; - m.ids (ic); - m.idrefs1 (rc1); - m.idrefs2 (rc2); + m.ids (XSD_MOVE (ic)); + m.idrefs1 (XSD_MOVE (rc1)); + m.idrefs2 (XSD_MOVE (rc2)); assert (m.idrefs1 ().idrefs ()[0].get () != 0); assert (m.idrefs1 ().idrefs ()[1].get () != 0); -- cgit v1.1