diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-09 18:14:37 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-09 18:14:37 +0200 |
commit | 34087db5762e86dcc60e596c70522303a623051c (patch) | |
tree | 76e7ad1c7356ba92fefd7c9ba424d31b035d37cd /odb/mysql/database.ixx | |
parent | fcd2821109dd056b46494c3f71e5a015e2c08736 (diff) |
Make database class move-constructible
This means it can be returned by value from a function in C++11.
Diffstat (limited to 'odb/mysql/database.ixx')
-rw-r--r-- | odb/mysql/database.ixx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/odb/mysql/database.ixx b/odb/mysql/database.ixx index 9e18ff7..5140103 100644 --- a/odb/mysql/database.ixx +++ b/odb/mysql/database.ixx @@ -2,12 +2,34 @@ // copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include <utility> // move() + #include <odb/mysql/transaction.hxx> namespace odb { namespace mysql { +#ifdef ODB_CXX11 + inline database:: + database (database&& db) // Has to be inline. + : odb::database (std::move (db)), + user_ (std::move (db.user_)), + passwd_str_ (std::move (db.passwd_str_)), + passwd_ (db.passwd_ != 0 ? passwd_str_.c_str () : 0), + db_ (std::move (db.db_)), + host_ (std::move (db.host_)), + port_ (db.port_), + socket_str_ (std::move (db.socket_str_)), + socket_ (db.socket_ != 0 ? socket_str_.c_str () : 0), + charset_ (std::move (db.charset_)), + client_flags_ (db.client_flags_), + factory_ (std::move (db.factory_)) + { + factory_->database (*this); // New database instance. + } +#endif + inline connection_ptr database:: connection () { |