You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Things like Database and Statement leverage RAII and own some kind of object, so it makes sense to make them non-copyable. However moving them around should be supported.
Consider the following:
classDatabaseWrapper {
SQLite::Database db;
SQLite::Statement query;
public:DatabaseWrapper() :
db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE)
// The following line doesn't work - "Table" still doesn't exist// , query(db, "select * from Table where X = ?")
{
SQLite::Transaction tr(db);
db.exec("create table Table (X varchar)");
tr.commit();
// Can't use copy assignment to innitialize `query`// query = SQLite::Statement(db, "select * from Table where X = ?");// No move constructor provided// query = std::move( SQLite::Statement(db, "select * from Table where X = ?") );
}
};
I was trying to use this to save time constructing the Statement in a tight loop.
The text was updated successfully, but these errors were encountered:
Ok, so the first thing to note is that the Database move ctor introduced in #157 is guarded by #if __cplusplus >= 201103L, which sadly does not work with Visual Studio.
Second thing is there is no unit tests nor examples to this.
I'll work to improve this asap, and then complete other classes with such move semantics as appropriate.
Things like
Database
andStatement
leverage RAII and own some kind of object, so it makes sense to make them non-copyable. However moving them around should be supported.Consider the following:
I was trying to use this to save time constructing the
Statement
in a tight loop.The text was updated successfully, but these errors were encountered: