Skip to content

Commit 2800b65

Browse files
committed
Set Statement move constractor to default; fix SRombauts#347
1 parent 6da299d commit 2800b65

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

include/SQLiteCpp/Column.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Column
5454
* @param[in] aStmtPtr Shared pointer to the prepared SQLite Statement Object.
5555
* @param[in] aIndex Index of the column in the row of result, starting at 0
5656
*/
57-
Column(Statement::TStatementPtr& aStmtPtr, int aIndex) noexcept;
57+
explicit Column(Statement::TStatementPtr& aStmtPtr, int aIndex) noexcept;
5858

5959
// default destructor: the finalization will be done by the destructor of the last shared pointer
6060
// default copy constructor and assignment operator are perfectly suited :
@@ -246,7 +246,7 @@ class Column
246246
*
247247
* @see getString
248248
*/
249-
operator std::string() const
249+
explicit operator std::string() const
250250
{
251251
return getString();
252252
}

include/SQLiteCpp/Statement.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class Statement
7979
*
8080
* @param[in] aStatement Statement to move
8181
*/
82-
Statement(Statement&& aStatement) noexcept;
82+
Statement(Statement&& aStatement) noexcept = default;
83+
Statement& operator=(Statement&& aStatement) noexcept = default;
8384

8485
// Statement is non-copyable
8586
Statement(const Statement&) = delete;

src/Statement.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ Statement::Statement(Database &aDatabase, const char* apQuery) :
2828
mColumnCount = sqlite3_column_count(mpPreparedStatement.get());
2929
}
3030

31-
Statement::Statement(Statement&& aStatement) noexcept :
32-
mQuery(std::move(aStatement.mQuery)),
33-
mpSQLite(aStatement.mpSQLite),
34-
mpPreparedStatement(std::move(aStatement.mpPreparedStatement)),
35-
mColumnCount(aStatement.mColumnCount),
36-
mbHasRow(aStatement.mbHasRow),
37-
mbDone(aStatement.mbDone)
38-
{
39-
aStatement.mpSQLite = nullptr;
40-
aStatement.mColumnCount = 0;
41-
aStatement.mbHasRow = false;
42-
aStatement.mbDone = false;
43-
}
44-
4531
// Reset the statement to make it ready for a new execution (see also #clearBindings() bellow)
4632
void Statement::reset()
4733
{
@@ -342,7 +328,7 @@ std::string Statement::getExpandedSQL() {
342328
Statement::TStatementPtr Statement::prepareStatement()
343329
{
344330
sqlite3_stmt* statement;
345-
const int ret = sqlite3_prepare_v2(mpSQLite, mQuery.c_str(), static_cast<int>(mQuery.size()), &statement, NULL);
331+
const int ret = sqlite3_prepare_v2(mpSQLite, mQuery.c_str(), static_cast<int>(mQuery.size()), &statement, nullptr);
346332
if (SQLITE_OK != ret)
347333
{
348334
throw SQLite::Exception(mpSQLite, ret);

0 commit comments

Comments
 (0)