From 16a4099d36ca1cdc33cf6e2b99edce796595341f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 8 Jan 2012 17:27:40 +0200 Subject: Add support for defining composite value type as class template instantiations --- common/composite/driver.cxx | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'common/composite/driver.cxx') diff --git a/common/composite/driver.cxx b/common/composite/driver.cxx index 606f367..a3825e1 100644 --- a/common/composite/driver.cxx +++ b/common/composite/driver.cxx @@ -122,6 +122,43 @@ main (int argc, char* argv[]) t.commit (); } } + + // Test composite class template instantiation. + // + { + object o (1); + + o.comp_.num = 123; + o.comp_.str = "abc"; + o.comp_.vec.push_back (int_str_pair (123, "abc")); + o.comp_.vec.push_back (int_str_pair (234, "bcd")); + o.comp_.vec.push_back (int_str_pair (345, "cde")); + + o.pair_.first = 123; + o.pair_.second = "abc"; + + o.vec_.push_back (int_str_pair (123, "abc")); + o.vec_.push_back (int_str_pair (234, "bcd")); + o.vec_.push_back (int_str_pair (345, "cde")); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } } catch (const odb::exception& e) { -- cgit v1.1