From 439bc0ff201f38025d224ce421c86ca44f3dc063 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Feb 2012 12:46:48 +0200 Subject: Test std::shared_ptr in C++11 mode and std::tr1::shared_ptr in C++98 mode --- common/relationship/driver.cxx | 6 +++--- common/relationship/test.hxx | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'common/relationship') diff --git a/common/relationship/driver.cxx b/common/relationship/driver.cxx index 879b123..20e0f0c 100644 --- a/common/relationship/driver.cxx +++ b/common/relationship/driver.cxx @@ -30,7 +30,7 @@ main (int argc, char* argv[]) aggr a ("aggr"); a.o1 = new obj1 ("o1", "obj1"); a.o2.reset (new obj2 ("obj2")); -#ifdef HAVE_TR1_MEMORY +#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) a.o3.reset (new obj3 ("obj3")); a.c.num = 123; @@ -60,7 +60,7 @@ main (int argc, char* argv[]) transaction t (db->begin ()); db->persist (a.o1); db->persist (a.o2); -#ifdef HAVE_TR1_MEMORY +#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) db->persist (a.o3); db->persist (a.c.o3); @@ -117,7 +117,7 @@ main (int argc, char* argv[]) delete a.o1; a.o1 = 0; a.o2.reset (); -#ifdef HAVE_TR1_MEMORY +#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) a.o3.reset (); #endif diff --git a/common/relationship/test.hxx b/common/relationship/test.hxx index bd18747..8b40dba 100644 --- a/common/relationship/test.hxx +++ b/common/relationship/test.hxx @@ -5,7 +5,7 @@ #ifndef TEST_HXX #define TEST_HXX -#include // HAVE_TR1_MEMORY +#include // HAVE_CXX11, HAVE_TR1_MEMORY #include #include @@ -15,7 +15,7 @@ #include -#ifdef HAVE_TR1_MEMORY +#if !defined(HAVE_CXX11) && defined(HAVE_TR1_MEMORY) # include #endif @@ -138,11 +138,16 @@ operator== (const obj2& x, const obj2& y) return x.id == y.id && x.str == y.str; } -// tr1::shared_ptr +// shared_ptr // -#ifdef HAVE_TR1_MEMORY +#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) struct obj3; + +#ifdef HAVE_CXX11 +typedef std::shared_ptr obj3_ptr; +#else typedef std::tr1::shared_ptr obj3_ptr; +#endif #pragma db object pointer(obj3_ptr) struct obj3 @@ -211,7 +216,7 @@ struct aggr obj1* o1; std::auto_ptr o2; -#ifdef HAVE_TR1_MEMORY +#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) obj3_ptr o3; comp c; comp_vec cv; @@ -235,7 +240,7 @@ operator== (const aggr& x, const aggr& y) x.id == y.id && (x.o1 ? (y.o1 && *x.o1 == *y.o1) : !y.o1) && (x.o2.get () ? (y.o2.get () && *x.o2 == *y.o2) : !y.o2.get ()) && -#ifdef HAVE_TR1_MEMORY +#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) (x.o3.get () ? (y.o3.get () && *x.o3 == *y.o3) : !y.o3.get ()) && x.c == y.c && x.cv == y.cv && -- cgit v1.1