From 72f9ee644d3a048e68ba9570a096b6dd12c5ee1a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Jun 2016 18:50:51 +0200 Subject: Get rid of C++11 deprecation warnings for auto_ptr, exception specs In particular, std::auto_ptr is no longer mapped in C++11. --- common/bulk/driver.cxx | 28 +++---- common/bulk/test.hxx | 26 +++---- common/const-member/test.hxx | 8 ++ common/const-object/driver.cxx | 20 +++++ common/const-object/test.hxx | 11 +++ common/container/change-tracking/driver.cxx | 15 +++- common/container/change-tracking/test.hxx | 4 + common/inheritance/polymorphism/driver.cxx | 110 ++++++++++++++++++++++++++++ common/inheritance/polymorphism/test5.hxx | 6 ++ common/inheritance/polymorphism/test6.hxx | 10 +++ common/prepared/driver.cxx | 12 ++- common/query/basics/test.hxx | 6 ++ common/readonly/test.hxx | 9 +++ common/wrapper/test.hxx | 4 + 14 files changed, 239 insertions(+), 30 deletions(-) (limited to 'common') diff --git a/common/bulk/driver.cxx b/common/bulk/driver.cxx index 06bd06c..d6a294a 100644 --- a/common/bulk/driver.cxx +++ b/common/bulk/driver.cxx @@ -327,13 +327,6 @@ main (int argc, char* argv[]) test (db, v.begin (), v.end ()); } - { - auto_ptr a[2]; - a[0].reset (new auto_object (1, "a")); - a[1].reset (new auto_object (2, "b")); - test (db, a, a + sizeof (a) / sizeof (a[0])); - } - #ifdef HAVE_CXX11 { vector> v; @@ -341,6 +334,13 @@ main (int argc, char* argv[]) v.push_back (unique_ptr (new unique_object (2, "b"))); test (db, v.begin (), v.end ()); } +#else + { + auto_ptr a[2]; + a[0].reset (new auto_object (1, "a")); + a[1].reset (new auto_object (2, "b")); + test (db, a, a + sizeof (a) / sizeof (a[0])); + } #endif { @@ -981,13 +981,6 @@ main (int argc, char* argv[]) test (db, v.begin (), v.end ()); } - { - auto_ptr a[2]; - a[0].reset (new auto_object (1, "a")); - a[1].reset (new auto_object (2, "b")); - test (db, a, a + sizeof (a) / sizeof (a[0])); - } - #ifdef HAVE_CXX11 { vector> v; @@ -995,6 +988,13 @@ main (int argc, char* argv[]) v.push_back (unique_ptr (new unique_object (2, "b"))); test (db, v.begin (), v.end ()); } +#else + { + auto_ptr a[2]; + a[0].reset (new auto_object (1, "a")); + a[1].reset (new auto_object (2, "b")); + test (db, a, a + sizeof (a) / sizeof (a[0])); + } #endif { diff --git a/common/bulk/test.hxx b/common/bulk/test.hxx index 85cb5c3..ce55158 100644 --- a/common/bulk/test.hxx +++ b/common/bulk/test.hxx @@ -32,10 +32,11 @@ namespace test1 std::string s; }; - #pragma db object bulk(3) pointer(std::auto_ptr) - struct auto_object +#ifdef HAVE_CXX11 + #pragma db object bulk(3) pointer(std::unique_ptr) + struct unique_object { - auto_object (unsigned int n_ = 0, std::string s_ = "") + unique_object (unsigned int n_ = 0, std::string s_ = "") : id (0), n (n_), s (s_) {} #pragma db id auto @@ -44,12 +45,11 @@ namespace test1 unsigned int n; std::string s; }; - -#ifdef HAVE_CXX11 - #pragma db object bulk(3) pointer(std::unique_ptr) - struct unique_object +#else + #pragma db object bulk(3) pointer(std::auto_ptr) + struct auto_object { - unique_object (unsigned int n_ = 0, std::string s_ = "") + auto_object (unsigned int n_ = 0, std::string s_ = "") : id (0), n (n_), s (s_) {} #pragma db id auto @@ -176,16 +176,16 @@ namespace test6 #pragma db object(object) bulk(3) #pragma db member(object::id) id auto - typedef object_template<2> auto_object; - - #pragma db object(auto_object) bulk(3) pointer(std::auto_ptr) - #pragma db member(auto_object::id) id auto - #ifdef HAVE_CXX11 typedef object_template<3> unique_object; #pragma db object(unique_object) bulk(3) pointer(std::unique_ptr) #pragma db member(unique_object::id) id auto +#else + typedef object_template<2> auto_object; + + #pragma db object(auto_object) bulk(3) pointer(std::auto_ptr) + #pragma db member(auto_object::id) id auto #endif } diff --git a/common/const-member/test.hxx b/common/const-member/test.hxx index 1928572..c858bbb 100644 --- a/common/const-member/test.hxx +++ b/common/const-member/test.hxx @@ -5,6 +5,8 @@ #ifndef TEST_HXX #define TEST_HXX +#include // HAVE_CXX11 + #include #include #include // std::auto_ptr @@ -102,9 +104,15 @@ struct wrapper #pragma db id unsigned long id; +#ifdef HAVE_CXX11 + const std::unique_ptr str; + const std::unique_ptr com; + const std::unique_ptr> vec; +#else const std::auto_ptr str; const std::auto_ptr com; const std::auto_ptr< const std::vector > vec; +#endif }; #endif // TEST_HXX diff --git a/common/const-object/driver.cxx b/common/const-object/driver.cxx index 03b9c20..cbe5b72 100644 --- a/common/const-object/driver.cxx +++ b/common/const-object/driver.cxx @@ -37,10 +37,18 @@ main (int argc, char* argv[]) const obj1* co1 (co1_); a.o1 = co1; +#ifdef HAVE_CXX11 + unique_ptr o2 (new obj2 (1)); +#else auto_ptr o2 (new obj2 (1)); +#endif obj2* co2_ (new obj2 (2)); a.o2.reset (co2_); +#ifdef HAVE_CXX11 + unique_ptr& co2 (a.o2); +#else auto_ptr& co2 (a.o2); +#endif // persist via references // @@ -75,8 +83,15 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr a (db->load (1)); + unique_ptr ca (db->load (2)); +#else auto_ptr a (db->load (1)); auto_ptr ca (db->load (2)); +#endif + t.commit (); assert (a->o1->id == 2); @@ -146,8 +161,13 @@ main (int argc, char* argv[]) { // i->f (); // error i->cf (); +#ifdef HAVE_CXX11 + //unique_ptr p (i.load ()); // error + unique_ptr p (i.load ()); +#else // auto_ptr p (i.load ()); // error auto_ptr p (i.load ()); +#endif obj2 o (0); i.load (o); assert (p->id == o.id); diff --git a/common/const-object/test.hxx b/common/const-object/test.hxx index 93977f0..2e73d96 100644 --- a/common/const-object/test.hxx +++ b/common/const-object/test.hxx @@ -5,6 +5,8 @@ #ifndef TEST_HXX #define TEST_HXX +#include // HAVE_CXX11 + #include #include @@ -21,7 +23,11 @@ struct obj1 void cf () const {} }; +#ifdef HAVE_CXX11 +#pragma db object pointer (std::unique_ptr) +#else #pragma db object pointer (std::auto_ptr) +#endif struct obj2 { obj2 () {} @@ -45,7 +51,12 @@ struct aggr int id; const obj1* o1; + +#ifdef HAVE_CXX11 + std::unique_ptr o2; +#else std::auto_ptr o2; +#endif }; #endif // TEST_HXX diff --git a/common/container/change-tracking/driver.cxx b/common/container/change-tracking/driver.cxx index c5a43a4..3db728c 100644 --- a/common/container/change-tracking/driver.cxx +++ b/common/container/change-tracking/driver.cxx @@ -137,7 +137,11 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); +#ifdef HAVE_CXX11 + unique_ptr p (db->load ("1")); +#else auto_ptr p (db->load ("1")); +#endif assert (p->s._tracking ()); t.commit (); } @@ -551,7 +555,11 @@ main (int argc, char* argv[]) // Armed copy. // { +#ifdef HAVE_CXX11 + unique_ptr c; +#else auto_ptr c; +#endif { o.s.pop_back (); @@ -616,7 +624,7 @@ main (int argc, char* argv[]) // #ifdef HAVE_CXX11 { - auto_ptr c; + unique_ptr c; { o.s.pop_back (); @@ -692,8 +700,13 @@ main (int argc, char* argv[]) { session s; transaction t (db->begin ()); +#ifdef HAVE_CXX11 + unique_ptr p1 (db->load (o1.id_)); + unique_ptr p2 (db->load (o2.id_)); +#else auto_ptr p1 (db->load (o1.id_)); auto_ptr p2 (db->load (o2.id_)); +#endif assert (p2->o1[0] == p1.get ()); assert (!p2->o1._tracking ()); t.commit (); diff --git a/common/container/change-tracking/test.hxx b/common/container/change-tracking/test.hxx index bcb6880..0117316 100644 --- a/common/container/change-tracking/test.hxx +++ b/common/container/change-tracking/test.hxx @@ -18,7 +18,11 @@ #include #include +#ifdef HAVE_CXX11 +#pragma db object pointer(std::unique_ptr) +#else #pragma db object pointer(std::auto_ptr) +#endif struct object { object () {} diff --git a/common/inheritance/polymorphism/driver.cxx b/common/inheritance/polymorphism/driver.cxx index 3eec9b6..acf94d5 100644 --- a/common/inheritance/polymorphism/driver.cxx +++ b/common/inheritance/polymorphism/driver.cxx @@ -1029,7 +1029,11 @@ main (int argc, char* argv[]) // Root. // { +#ifdef HAVE_CXX11 + unique_ptr p (db->load (r.id)); +#else auto_ptr p (db->load (r.id)); +#endif r.num++; r.strs.push_back ("aaaa"); @@ -1053,7 +1057,11 @@ main (int argc, char* argv[]) // Base. // { +#ifdef HAVE_CXX11 + unique_ptr p (db->load (b.id)); +#else auto_ptr p (db->load (b.id)); +#endif b.num++; b.str += "b"; @@ -1081,7 +1089,11 @@ main (int argc, char* argv[]) // Derived. // { +#ifdef HAVE_CXX11 + unique_ptr p (db->load (d.id)); // Via root. +#else auto_ptr p (db->load (d.id)); // Via root. +#endif d.num++; d.str += "d"; @@ -1145,7 +1157,11 @@ main (int argc, char* argv[]) // Root. // { +#ifdef HAVE_CXX11 + unique_ptr p (db->load (r.id)); +#else auto_ptr p (db->load (r.id)); +#endif r.num++; r.strs.push_back ("aaaaa"); @@ -1165,7 +1181,11 @@ main (int argc, char* argv[]) // Base. // { +#ifdef HAVE_CXX11 + unique_ptr p (db->load (b.id)); +#else auto_ptr p (db->load (b.id)); +#endif b.num++; b.str += "b"; @@ -1187,7 +1207,11 @@ main (int argc, char* argv[]) // Derived. // { +#ifdef HAVE_CXX11 + unique_ptr p (db->load (d.id)); // Via root. +#else auto_ptr p (db->load (d.id)); // Via root. +#endif d.num++; d.str += "d"; @@ -1240,7 +1264,12 @@ main (int argc, char* argv[]) using namespace test6; base b (1, 1, "bbb"); + +#ifdef HAVE_CXX11 + unique_ptr d (new derived (2, 2, "ddd")); +#else auto_ptr d (new derived (2, 2, "ddd")); +#endif // Persist. // @@ -1256,8 +1285,13 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d->id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd (db->load (d->id)); +#endif db->load (b.id, *pb); db->load (d->id, *pd); @@ -1319,7 +1353,12 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr p (db->load (d.id)); +#else auto_ptr p (db->load (d.id)); +#endif t.commit (); } } @@ -1479,9 +1518,15 @@ main (int argc, char* argv[]) // load (id) // +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd1 (db->load (d1.id)); + unique_ptr pd2 (db->load (d2.id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd1 (db->load (d1.id)); auto_ptr pd2 (db->load (d2.id)); +#endif assert (*pb == b); assert (*pd1 == d1); @@ -1563,9 +1608,17 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd1 (db->load (d1.id)); + unique_ptr pd2 (db->load (d2.id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd1 (db->load (d1.id)); auto_ptr pd2 (db->load (d2.id)); +#endif + t.commit (); assert (*pb == b); @@ -1690,6 +1743,16 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr p_ro_r (db->load (ro_r.id)); + unique_ptr p_rw_b (db->load (rw_b.id)); + unique_ptr p_ro_d (db->load (ro_d.id)); + + unique_ptr p_rw_r (db->load (rw_r.id)); + unique_ptr p_ro_b (db->load (ro_b.id)); + unique_ptr p_rw_d (db->load (rw_d.id)); +#else auto_ptr p_ro_r (db->load (ro_r.id)); auto_ptr p_rw_b (db->load (rw_b.id)); auto_ptr p_ro_d (db->load (ro_d.id)); @@ -1697,6 +1760,8 @@ main (int argc, char* argv[]) auto_ptr p_rw_r (db->load (rw_r.id)); auto_ptr p_ro_b (db->load (ro_b.id)); auto_ptr p_rw_d (db->load (rw_d.id)); +#endif + t.commit (); assert (*p_ro_r == ro_r); @@ -1730,8 +1795,14 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd (db->load (d.id)); +#endif t.commit (); assert (*pb == b); @@ -1754,8 +1825,14 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd (db->load (d.id)); +#endif t.commit (); assert (*pb == b); @@ -1790,8 +1867,14 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd (db->load (d.id)); +#endif t.commit (); assert (*pb == b); @@ -1823,8 +1906,15 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); +#else auto_ptr pb (db->load (b.id)); auto_ptr pd (db->load (d.id)); +#endif + t.commit (); assert (*pb == b); @@ -1885,8 +1975,15 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (id1)); + unique_ptr pd (db->load (id2)); +#else auto_ptr pb (db->load (id1)); auto_ptr pd (db->load (id2)); +#endif + t.commit (); assert (*pb == b); @@ -1922,10 +2019,18 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pbr (db->load (b.id)); + unique_ptr pdr (db->load (d.id)); + unique_ptr pdb (db->load (d.id)); + unique_ptr pb1r (db->load (b1.id)); +#else auto_ptr pbr (db->load (b.id)); auto_ptr pdr (db->load (d.id)); auto_ptr pdb (db->load (d.id)); auto_ptr pb1r (db->load (b1.id)); +#endif t.commit (); base& rb (static_cast (*pbr)); @@ -2044,7 +2149,12 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); + +#ifdef HAVE_CXX11 + unique_ptr pb (db->load (d.id)); +#else auto_ptr pb (db->load (d.id)); +#endif t.commit (); derived* pd (dynamic_cast (pb.get ())); diff --git a/common/inheritance/polymorphism/test5.hxx b/common/inheritance/polymorphism/test5.hxx index e253f6a..78f909f 100644 --- a/common/inheritance/polymorphism/test5.hxx +++ b/common/inheritance/polymorphism/test5.hxx @@ -5,6 +5,8 @@ #ifndef TEST5_HXX #define TEST5_HXX +#include // HAVE_CXX11 + #include #include #include @@ -17,7 +19,11 @@ #pragma db namespace table("t5_") namespace test5 { +#ifdef HAVE_CXX11 + #pragma db object polymorphic optimistic pointer(std::unique_ptr) +#else #pragma db object polymorphic optimistic pointer(std::auto_ptr) +#endif struct root { virtual ~root () {} diff --git a/common/inheritance/polymorphism/test6.hxx b/common/inheritance/polymorphism/test6.hxx index 1682b3f..c12b5f4 100644 --- a/common/inheritance/polymorphism/test6.hxx +++ b/common/inheritance/polymorphism/test6.hxx @@ -5,6 +5,8 @@ #ifndef TEST6_HXX #define TEST6_HXX +#include // HAVE_CXX11 + #include #include @@ -16,7 +18,11 @@ #pragma db namespace table("t6_") namespace test6 { +#ifdef HAVE_CXX11 + #pragma db object polymorphic pointer(std::unique_ptr) +#else #pragma db object polymorphic pointer(std::auto_ptr) +#endif struct root { virtual ~root () {} @@ -55,7 +61,11 @@ namespace test6 unsigned long dnum; std::string dstr; +#ifdef HAVE_CXX11 + std::unique_ptr ptr; +#else std::auto_ptr ptr; +#endif void db_callback (odb::callback_event, odb::database&) const; diff --git a/common/prepared/driver.cxx b/common/prepared/driver.cxx index 0d30821..0467f70 100644 --- a/common/prepared/driver.cxx +++ b/common/prepared/driver.cxx @@ -33,13 +33,21 @@ query_factory (const char* name, connection& c) { typedef odb::query query; +#ifdef HAVE_CXX11 + unique_ptr p (new params); +#else auto_ptr p (new params); +#endif prepared_query pq ( c.prepare_query ( name, query::age > query::_ref (p->age) && query::name != query::_ref (p->name))); +#ifdef HAVE_CXX11 + c.cache_query (pq, move (p)); +#else c.cache_query (pq, p); +#endif } int @@ -286,13 +294,13 @@ main (int argc, char* argv[]) { typedef odb::query query; - auto_ptr p (new params); + unique_ptr p (new params); prepared_query pq ( c.prepare_query ( name, query::age > query::_ref (p->age) && query::name != query::_ref (p->name))); - c.cache_query (pq, p); + c.cache_query (pq, move (p)); }); for (unsigned int i (1); i < 6; ++i) diff --git a/common/query/basics/test.hxx b/common/query/basics/test.hxx index 3e61c57..74b5ff5 100644 --- a/common/query/basics/test.hxx +++ b/common/query/basics/test.hxx @@ -5,6 +5,8 @@ #ifndef TEST_HXX #define TEST_HXX +#include // HAVE_CXX11 + #include #include #include @@ -55,7 +57,11 @@ struct person std::string first_name_; #pragma db column ("middle") null +#ifdef HAVE_CXX11 + std::unique_ptr middle_name_; +#else std::auto_ptr middle_name_; +#endif #pragma db column ("last") std::string last_name_; diff --git a/common/readonly/test.hxx b/common/readonly/test.hxx index 689b571..926b596 100644 --- a/common/readonly/test.hxx +++ b/common/readonly/test.hxx @@ -5,6 +5,8 @@ #ifndef TEST_HXX #define TEST_HXX +#include // HAVE_CXX11 + #include #include // std::auto_ptr @@ -203,10 +205,17 @@ struct wrapper #pragma db id unsigned long id; +#ifdef HAVE_CXX11 + std::unique_ptr pl; + const std::unique_ptr cpl; + std::unique_ptr pcl; + const std::unique_ptr cpcl; +#else std::auto_ptr pl; const std::auto_ptr cpl; std::auto_ptr pcl; const std::auto_ptr cpcl; +#endif }; // Readonly object with auto id. diff --git a/common/wrapper/test.hxx b/common/wrapper/test.hxx index 9e3dc2b..36aec87 100644 --- a/common/wrapper/test.hxx +++ b/common/wrapper/test.hxx @@ -231,7 +231,11 @@ namespace test5 unsigned long id; #pragma db null +#ifdef HAVE_CXX11 + std::unique_ptr p; +#else std::auto_ptr p; +#endif odb::nullable n; -- cgit v1.1