File tree Expand file tree Collapse file tree 3 files changed +51
-5
lines changed Expand file tree Collapse file tree 3 files changed +51
-5
lines changed Original file line number Diff line number Diff line change @@ -2752,14 +2752,14 @@ $as_echo "no" >&6; }
2752
2752
2753
2753
if test " " == " "
2754
2754
then
2755
- { $as_echo " $as_me :${as_lineno-$LINENO } : checking if compiler flag -std=c++11 works" >&5
2756
- $as_echo_n " checking if compiler flag -std=c++11 works... " >&6 ; }
2755
+ { $as_echo " $as_me :${as_lineno-$LINENO } : checking if compiler flag -std=c++14 works" >&5
2756
+ $as_echo_n " checking if compiler flag -std=c++14 works... " >&6 ; }
2757
2757
else
2758
2758
{ $as_echo " $as_me :${as_lineno-$LINENO } : checking " >&5
2759
2759
$as_echo_n " checking ... " >&6 ; }
2760
2760
fi
2761
2761
save_CXXFLAGS=" $CXXFLAGS "
2762
- CXXFLAGS=" $CXXFLAGS -std=c++11 "
2762
+ CXXFLAGS=" $CXXFLAGS -std=c++14 "
2763
2763
2764
2764
2765
2765
Original file line number Diff line number Diff line change @@ -111,12 +111,19 @@ namespace sqlite {
111
111
class database_binder {
112
112
113
113
public:
114
- database_binder (database_binder&& other) = default ;
115
114
// database_binder is not copyable
116
115
database_binder () = delete ;
117
116
database_binder (const database_binder& other) = delete ;
118
117
database_binder& operator =(const database_binder&) = delete ;
119
118
119
+ database_binder (database_binder&& other) :
120
+ _db (std::move(other._db)),
121
+ _sql (std::move(other._sql)),
122
+ _stmt (std::move(other._stmt)),
123
+ _inx (other._inx), execution_started(other.execution_started) {
124
+ _db = nullptr ;
125
+ _stmt = nullptr ;
126
+ }
120
127
121
128
void reset () {
122
129
sqlite3_reset (_stmt.get ());
@@ -253,7 +260,7 @@ namespace sqlite {
253
260
~database_binder () noexcept (false ) {
254
261
/* Will be executed if no >>op is found, but not if an exception
255
262
is in mid flight */
256
- if (!execution_started && !std::uncaught_exception ()) {
263
+ if (!execution_started && !std::uncaught_exception () && _stmt ) {
257
264
execute ();
258
265
}
259
266
}
Original file line number Diff line number Diff line change
1
+ // Fixing https://github.com/aminroosta/sqlite_modern_cpp/issues/63
2
+ #include < iostream>
3
+ #include < cstdlib>
4
+ #include < unistd.h>
5
+ #include < sqlite_modern_cpp.h>
6
+ #include < memory>
7
+ using namespace sqlite ;
8
+ using namespace std ;
9
+
10
+ struct dbFront {
11
+ std::unique_ptr<database_binder> storedProcedure;
12
+ database db;
13
+ dbFront (): db(" :memory:" ) {
14
+ db << " CREATE TABLE tbl (id integer, name string);" ;
15
+ // the temporary moved object should not run _execute() function on destruction.
16
+ storedProcedure = std::make_unique<database_binder>(
17
+ db << " INSERT INTO tbl VALUES (?, ?);"
18
+ );
19
+ }
20
+ };
21
+
22
+
23
+ int main () {
24
+
25
+ try {
26
+ dbFront dbf;
27
+ }
28
+ catch (sqlite_exception e) {
29
+ cout << " Unexpected error " << e.what () << endl;
30
+ exit (EXIT_FAILURE);
31
+ }
32
+ catch (...) {
33
+ cout << " Unknown error\n " ;
34
+ exit (EXIT_FAILURE);
35
+ }
36
+
37
+ cout << " OK\n " ;
38
+ exit (EXIT_SUCCESS);
39
+ }
You can’t perform that action at this time.
0 commit comments