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/inheritance/polymorphism/driver.cxx | 110 +++++++++++++++++++++++++++++ common/inheritance/polymorphism/test5.hxx | 6 ++ common/inheritance/polymorphism/test6.hxx | 10 +++ 3 files changed, 126 insertions(+) (limited to 'common/inheritance/polymorphism') 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; -- cgit v1.1