From 0b641f182c0b89b0c903f8756aa14b6b3a2f60f2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Aug 2011 13:32:25 +0200 Subject: Add support for boost::optional and boost::shared_ptr as value wrappers New test: boost/common/optional. --- boost/common/smart-ptr/driver.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'boost/common/smart-ptr/driver.cxx') diff --git a/boost/common/smart-ptr/driver.cxx b/boost/common/smart-ptr/driver.cxx index eaa4bbd..af5767c 100644 --- a/boost/common/smart-ptr/driver.cxx +++ b/boost/common/smart-ptr/driver.cxx @@ -169,6 +169,31 @@ main (int argc, char* argv[]) t.commit (); } + + // + // Test shared_ptr as a value wrapper. + // + + { + obj2 o1 (1); + obj2 o2 (2); + o2.str.reset (new string ("abc")); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + shared_ptr o1 (db->load (1)); + shared_ptr o2 (db->load (2)); + t.commit (); + + assert (!o1->str); + assert (o2->str && *o2->str == "abc"); + } } catch (const odb::exception& e) { -- cgit v1.1