Skip to content

Commit a5f9f6e

Browse files
committed
Fix bugs
1 parent 3d7e040 commit a5f9f6e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

hdr/sqlite_modern_cpp.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,26 +295,32 @@ namespace sqlite {
295295
public:
296296
value_type(database_binder *_binder): _binder(_binder) {};
297297
template<class T>
298-
value_type &operator >>(T &result) {
298+
typename std::enable_if<database_binder::is_sqlite_value<T>::value, value_type &>::type operator >>(T &result) {
299299
get_col_from_db(*_binder, next_index++, result);
300300
return *this;
301301
}
302+
template<class T, typename = typename std::enable_if<database_binder::is_sqlite_value<T>::value, value_type &>::type>
303+
operator T() {
304+
T result;
305+
*this >> result;
306+
return result;
307+
}
302308
template<class ...Types>
303309
value_type &operator >>(std::tuple<Types...>& values) {
304310
assert(!next_index);
305311
tuple_iterate<std::tuple<Types...>>::iterate(values, *_binder);
306312
next_index = sizeof...(Types) + 1;
307313
return *this;
308314
}
309-
explicit operator bool() {
310-
return sqlite3_column_count(_binder->_stmt.get()) >= next_index;
311-
}
312-
template<class Type>
313-
operator Type() {
314-
Type value;
315+
template<class ...Types>
316+
operator std::tuple<Types...>() {
317+
std::tuple<Types...> value;
315318
*this >> value;
316319
return value;
317320
}
321+
explicit operator bool() {
322+
return sqlite3_column_count(_binder->_stmt.get()) >= next_index;
323+
}
318324
private:
319325
database_binder *_binder;
320326
int next_index = 0;
@@ -342,7 +348,6 @@ namespace sqlite {
342348
_binder = nullptr;
343349
break;
344350
default:
345-
_binder = nullptr;
346351
exceptions::throw_sqlite_error(result, _binder->sql());
347352
}
348353
return *this;

0 commit comments

Comments
 (0)