Skip to content

Commit 678562e

Browse files
committed
Implement Database move constructors for MSVC SRombauts#190
Added checks to proper _MSC_VER 1600 (VS2010)
1 parent cb6c16a commit 678562e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,8 @@ Version 2.3.0 - March 3 2019
127127
- Added tests for all MSVC compilers available on AppVeyor (2013, 2015, 2017) #169
128128
- Update VariadicBind.h #172
129129
- Better CMake compatibility #170
130-
- Add implicit cast operator to char and short types #179 #180
130+
- Add implicit cast operator to char and short types #179 #180
131+
132+
Version ?
133+
- #191 CMake Warning line 299
134+
- #190 Implement move constructors

include/SQLiteCpp/Database.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Database
120120
const int aBusyTimeoutMs = 0,
121121
const std::string& aVfs = "");
122122

123-
#if __cplusplus >= 201103L
123+
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
124124
/**
125125
* @brief Move an SQLite database connection.
126126
*

tests/Database_test.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ TEST(Database, ctorExecCreateDropExist) {
6363
remove("test.db3");
6464
}
6565

66+
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
67+
TEST(Database, moveConstructor) {
68+
remove("test.db3");
69+
{
70+
// Create a new database
71+
SQLite::Database db("test.db3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
72+
EXPECT_FALSE(db.tableExists("test"));
73+
EXPECT_TRUE(db.getHandle() != NULL);
74+
SQLite::Database moved = std::move(db);
75+
EXPECT_TRUE(db.getHandle() == NULL);
76+
EXPECT_TRUE(moved.getHandle() != NULL);
77+
EXPECT_FALSE(moved.tableExists("test"));
78+
} // Close DB test.db3
79+
remove("test.db3");
80+
}
81+
#endif
82+
6683
TEST(Database, createCloseReopen) {
6784
remove("test.db3");
6885
{

0 commit comments

Comments
 (0)