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; }
27522752
27532753 if test " " == " "
27542754 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 ; }
27572757 else
27582758 { $as_echo " $as_me :${as_lineno-$LINENO } : checking " >&5
27592759$as_echo_n " checking ... " >&6 ; }
27602760 fi
27612761 save_CXXFLAGS=" $CXXFLAGS "
2762- CXXFLAGS=" $CXXFLAGS -std=c++11 "
2762+ CXXFLAGS=" $CXXFLAGS -std=c++14 "
27632763
27642764
27652765
Original file line number Diff line number Diff line change @@ -111,12 +111,19 @@ namespace sqlite {
111111 class database_binder {
112112
113113 public:
114- database_binder (database_binder&& other) = default ;
115114 // database_binder is not copyable
116115 database_binder () = delete ;
117116 database_binder (const database_binder& other) = delete ;
118117 database_binder& operator =(const database_binder&) = delete ;
119118
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+ }
120127
121128 void reset () {
122129 sqlite3_reset (_stmt.get ());
@@ -253,7 +260,7 @@ namespace sqlite {
253260 ~database_binder () noexcept (false ) {
254261 /* Will be executed if no >>op is found, but not if an exception
255262 is in mid flight */
256- if (!execution_started && !std::uncaught_exception ()) {
263+ if (!execution_started && !std::uncaught_exception () && _stmt ) {
257264 execute ();
258265 }
259266 }
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