From 65f719d82b8682d567c7166e066b8e12039ad066 Mon Sep 17 00:00:00 2001 From: hubslave <29800872+hubslave@users.noreply.github.com> Date: Thu, 29 Mar 2018 16:48:16 +0300 Subject: [PATCH] Add a move constructor to Database This makes it possible to e.g. return Databases from functions. Gated behind a __cplusplus >= 201103L check for compatibility with older C++ versions. --- include/SQLiteCpp/Database.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index d46f736..f0e9d75 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -120,6 +120,20 @@ public: const int aBusyTimeoutMs = 0, const std::string& aVfs = ""); +#if __cplusplus >= 201103L + /** + * @brief Move an SQLite database connection. + * + * @param[in] aDb Database to move + */ + inline Database(Database&& aDb) noexcept : + mpSQLite(aDb.mpSQLite), + mFilename(std::move(aDb.mFilename)) + { + aDb.mpSQLite = nullptr; + } +#endif + /** * @brief Close the SQLite database connection. *