diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-15 18:50:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-15 18:50:51 +0200 |
commit | a5a31413ef7b81755475da8a705e6aea9ad28aac (patch) | |
tree | 7b9a53612ea2362c9ca30cff26b4a5d9e80c16dc | |
parent | 4bc35f8c792febe867ee6b72663c2ca15c6ed5ac (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.
-rw-r--r-- | prepared/driver.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/prepared/driver.cxx b/prepared/driver.cxx index d805ddb..c5b5b22 100644 --- a/prepared/driver.cxx +++ b/prepared/driver.cxx @@ -1,14 +1,17 @@ // file : prepared/driver.cxx // copyright : not copyrighted - public domain -#include <memory> // std::auto_ptr +#include <memory> // std::auto_ptr/unique_ptr #include <cassert> +#include <utility> // std::move() #include <iostream> #include <odb/database.hxx> #include <odb/connection.hxx> #include <odb/transaction.hxx> +#include <odb/details/config.hxx> // ODB_CXX11 + #include "database.hxx" // create_database #include "person.hxx" @@ -28,11 +31,19 @@ query_factory (const char* name, connection& c) { typedef odb::query<person> query; +#ifdef ODB_CXX11 + unique_ptr<params> p (new params); + query q (query::age > query::_ref (p->age) && + query::first == query::_ref (p->first)); + prepared_query<person> pq (c.prepare_query<person> (name, q)); + c.cache_query (pq, move (p)); +#else auto_ptr<params> p (new params); query q (query::age > query::_ref (p->age) && query::first == query::_ref (p->first)); prepared_query<person> pq (c.prepare_query<person> (name, q)); c.cache_query (pq, p); +#endif } static void @@ -150,11 +161,19 @@ main (int argc, char* argv[]) if (!pq) { +#ifdef ODB_CXX11 + unique_ptr<unsigned short> p (new unsigned short); + age_param = p.get (); + query q (query::age > query::_ref (*age_param)); + pq = db->prepare_query<person> ("person-ref-age-query", q); + db->cache_query (pq, move (p)); +#else auto_ptr<unsigned short> p (new unsigned short); age_param = p.get (); query q (query::age > query::_ref (*age_param)); pq = db->prepare_query<person> ("person-ref-age-query", q); db->cache_query (pq, p); // Assumes ownership of p. +#endif } *age_param = age; // Initialize the parameter. |