Skip to content

Commit

Permalink
Restored Statement move constructor for compatibility with older comp…
Browse files Browse the repository at this point in the history
…ilers
  • Loading branch information
Kacperos155 committed Jan 26, 2022
1 parent 27a3252 commit c5b3aa8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/SQLiteCpp/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Statement
*
* @param[in] aStatement Statement to move
*/
Statement(Statement&& aStatement) noexcept = default;
Statement(Statement&& aStatement) noexcept;
Statement& operator=(Statement&& aStatement) noexcept = default;

// Statement is non-copyable
Expand Down
15 changes: 15 additions & 0 deletions src/Statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ Statement::Statement(const Database& aDatabase, const char* apQuery) :
mColumnCount = sqlite3_column_count(mpPreparedStatement.get());
}

Statement::Statement(Statement&& aStatement) noexcept :
mQuery(std::move(aStatement.mQuery)),
mpSQLite(aStatement.mpSQLite),
mpPreparedStatement(std::move(aStatement.mpPreparedStatement)),
mColumnCount(aStatement.mColumnCount),
mbHasRow(aStatement.mbHasRow),
mbDone(aStatement.mbDone),
mColumnNames(std::move(aStatement.mColumnNames))
{
aStatement.mpSQLite = nullptr;
aStatement.mColumnCount = 0;
aStatement.mbHasRow = false;
aStatement.mbDone = false;
}

// Reset the statement to make it ready for a new execution (see also #clearBindings() bellow)
void Statement::reset()
{
Expand Down

0 comments on commit c5b3aa8

Please sign in to comment.