aboutsummaryrefslogtreecommitdiff
path: root/common/inheritance
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-06-15 18:50:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-06-15 18:50:51 +0200
commit72f9ee644d3a048e68ba9570a096b6dd12c5ee1a (patch)
tree5670eaa8c20845b401c0b09bd0d643b971c675d9 /common/inheritance
parent766b7533addb5c981b135640321c291be270d907 (diff)
Get rid of C++11 deprecation warnings for auto_ptr, exception specs
In particular, std::auto_ptr is no longer mapped in C++11.
Diffstat (limited to 'common/inheritance')
-rw-r--r--common/inheritance/polymorphism/driver.cxx110
-rw-r--r--common/inheritance/polymorphism/test5.hxx6
-rw-r--r--common/inheritance/polymorphism/test6.hxx10
3 files changed, 126 insertions, 0 deletions
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<root> p (db->load<root> (r.id));
+#else
auto_ptr<root> p (db->load<root> (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<base> p (db->load<base> (b.id));
+#else
auto_ptr<base> p (db->load<base> (b.id));
+#endif
b.num++;
b.str += "b";
@@ -1081,7 +1089,11 @@ main (int argc, char* argv[])
// Derived.
//
{
+#ifdef HAVE_CXX11
+ unique_ptr<root> p (db->load<root> (d.id)); // Via root.
+#else
auto_ptr<root> p (db->load<root> (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<root> p (db->load<root> (r.id));
+#else
auto_ptr<root> p (db->load<root> (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<base> p (db->load<base> (b.id));
+#else
auto_ptr<base> p (db->load<base> (b.id));
+#endif
b.num++;
b.str += "b";
@@ -1187,7 +1207,11 @@ main (int argc, char* argv[])
// Derived.
//
{
+#ifdef HAVE_CXX11
+ unique_ptr<root> p (db->load<root> (d.id)); // Via root.
+#else
auto_ptr<root> p (db->load<root> (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<base> d (new derived (2, 2, "ddd"));
+#else
auto_ptr<base> 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<base> pb (db->load<base> (b.id));
+ unique_ptr<root> pd (db->load<root> (d->id));
+#else
auto_ptr<base> pb (db->load<base> (b.id));
auto_ptr<root> pd (db->load<root> (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<root> p (db->load<root> (d.id));
+#else
auto_ptr<root> p (db->load<root> (d.id));
+#endif
t.commit ();
}
}
@@ -1479,9 +1518,15 @@ main (int argc, char* argv[])
// load (id)
//
+#ifdef HAVE_CXX11
+ unique_ptr<root> pb (db->load<root> (b.id));
+ unique_ptr<interm> pd1 (db->load<interm> (d1.id));
+ unique_ptr<derived2> pd2 (db->load<derived2> (d2.id));
+#else
auto_ptr<root> pb (db->load<root> (b.id));
auto_ptr<interm> pd1 (db->load<interm> (d1.id));
auto_ptr<derived2> pd2 (db->load<derived2> (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<base> pb (db->load<base> (b.id));
+ unique_ptr<root> pd1 (db->load<root> (d1.id));
+ unique_ptr<base> pd2 (db->load<base> (d2.id));
+#else
auto_ptr<base> pb (db->load<base> (b.id));
auto_ptr<root> pd1 (db->load<root> (d1.id));
auto_ptr<base> pd2 (db->load<base> (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<ro_root> p_ro_r (db->load<ro_root> (ro_r.id));
+ unique_ptr<ro_root> p_rw_b (db->load<ro_root> (rw_b.id));
+ unique_ptr<ro_root> p_ro_d (db->load<ro_root> (ro_d.id));
+
+ unique_ptr<rw_root> p_rw_r (db->load<rw_root> (rw_r.id));
+ unique_ptr<rw_root> p_ro_b (db->load<rw_root> (ro_b.id));
+ unique_ptr<rw_root> p_rw_d (db->load<rw_root> (rw_d.id));
+#else
auto_ptr<ro_root> p_ro_r (db->load<ro_root> (ro_r.id));
auto_ptr<ro_root> p_rw_b (db->load<ro_root> (rw_b.id));
auto_ptr<ro_root> p_ro_d (db->load<ro_root> (ro_d.id));
@@ -1697,6 +1760,8 @@ main (int argc, char* argv[])
auto_ptr<rw_root> p_rw_r (db->load<rw_root> (rw_r.id));
auto_ptr<rw_root> p_ro_b (db->load<rw_root> (ro_b.id));
auto_ptr<rw_root> p_rw_d (db->load<rw_root> (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<root> pb (db->load<root> (b.id));
+ unique_ptr<root> pd (db->load<root> (d.id));
+#else
auto_ptr<root> pb (db->load<root> (b.id));
auto_ptr<root> pd (db->load<root> (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<root> pb (db->load<root> (b.id));
+ unique_ptr<root> pd (db->load<root> (d.id));
+#else
auto_ptr<root> pb (db->load<root> (b.id));
auto_ptr<root> pd (db->load<root> (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<base> pb (db->load<base> (b.id));
+ unique_ptr<base> pd (db->load<base> (d.id));
+#else
auto_ptr<base> pb (db->load<base> (b.id));
auto_ptr<base> pd (db->load<base> (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<base> pb (db->load<base> (b.id));
+ unique_ptr<base> pd (db->load<base> (d.id));
+#else
auto_ptr<base> pb (db->load<base> (b.id));
auto_ptr<base> pd (db->load<base> (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<root> pb (db->load<root> (id1));
+ unique_ptr<root> pd (db->load<root> (id2));
+#else
auto_ptr<root> pb (db->load<root> (id1));
auto_ptr<root> pd (db->load<root> (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<root> pbr (db->load<root> (b.id));
+ unique_ptr<root> pdr (db->load<root> (d.id));
+ unique_ptr<base> pdb (db->load<base> (d.id));
+ unique_ptr<root> pb1r (db->load<root> (b1.id));
+#else
auto_ptr<root> pbr (db->load<root> (b.id));
auto_ptr<root> pdr (db->load<root> (d.id));
auto_ptr<base> pdb (db->load<base> (d.id));
auto_ptr<root> pb1r (db->load<root> (b1.id));
+#endif
t.commit ();
base& rb (static_cast<base&> (*pbr));
@@ -2044,7 +2149,12 @@ main (int argc, char* argv[])
//
{
transaction t (db->begin ());
+
+#ifdef HAVE_CXX11
+ unique_ptr<base> pb (db->load<base> (d.id));
+#else
auto_ptr<base> pb (db->load<base> (d.id));
+#endif
t.commit ();
derived* pd (dynamic_cast<derived*> (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 <common/config.hxx> // HAVE_CXX11
+
#include <string>
#include <vector>
#include <memory>
@@ -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 <common/config.hxx> // HAVE_CXX11
+
#include <string>
#include <memory>
@@ -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<root> ptr;
+#else
std::auto_ptr<root> ptr;
+#endif
void
db_callback (odb::callback_event, odb::database&) const;