aboutsummaryrefslogtreecommitdiff
path: root/common/const-object
diff options
context:
space:
mode:
Diffstat (limited to 'common/const-object')
-rw-r--r--common/const-object/driver.cxx20
-rw-r--r--common/const-object/test.hxx11
2 files changed, 31 insertions, 0 deletions
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<obj2> o2 (new obj2 (1));
+#else
auto_ptr<obj2> o2 (new obj2 (1));
+#endif
obj2* co2_ (new obj2 (2));
a.o2.reset (co2_);
+#ifdef HAVE_CXX11
+ unique_ptr<const obj2>& co2 (a.o2);
+#else
auto_ptr<const obj2>& 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<aggr> a (db->load<aggr> (1));
+ unique_ptr<const aggr> ca (db->load<aggr> (2));
+#else
auto_ptr<aggr> a (db->load<aggr> (1));
auto_ptr<const aggr> ca (db->load<aggr> (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<obj2> p (i.load ()); // error
+ unique_ptr<const obj2> p (i.load ());
+#else
// auto_ptr<obj2> p (i.load ()); // error
auto_ptr<const obj2> 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 <common/config.hxx> // HAVE_CXX11
+
#include <memory>
#include <odb/core.hxx>
@@ -21,7 +23,11 @@ struct obj1
void cf () const {}
};
+#ifdef HAVE_CXX11
+#pragma db object pointer (std::unique_ptr<obj2>)
+#else
#pragma db object pointer (std::auto_ptr<obj2>)
+#endif
struct obj2
{
obj2 () {}
@@ -45,7 +51,12 @@ struct aggr
int id;
const obj1* o1;
+
+#ifdef HAVE_CXX11
+ std::unique_ptr<const obj2> o2;
+#else
std::auto_ptr<const obj2> o2;
+#endif
};
#endif // TEST_HXX