File tree 1 file changed +13
-8
lines changed
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -276,26 +276,32 @@ namespace sqlite {
276
276
public:
277
277
value_type (database_binder *_binder): _binder(_binder) {};
278
278
template <class T >
279
- value_type &operator >>(T &result) {
279
+ typename std::enable_if<database_binder::is_sqlite_value<T>::value, value_type &>::type operator >>(T &result) {
280
280
get_col_from_db (*_binder, next_index++, result);
281
281
return *this ;
282
282
}
283
+ template <class T , typename = typename std::enable_if<database_binder::is_sqlite_value<T>::value, value_type &>::type>
284
+ operator T () {
285
+ T result;
286
+ *this >> result;
287
+ return result;
288
+ }
283
289
template <class ...Types>
284
290
value_type &operator >>(std::tuple<Types...>& values) {
285
291
assert (!next_index);
286
292
tuple_iterate<std::tuple<Types...>>::iterate(values, *_binder);
287
293
next_index = sizeof ...(Types) + 1 ;
288
294
return *this ;
289
295
}
290
- explicit operator bool () {
291
- return sqlite3_column_count (_binder->_stmt .get ()) >= next_index;
292
- }
293
- template <class Type >
294
- operator Type () {
295
- Type value;
296
+ template <class ...Types>
297
+ operator std::tuple<Types...>() {
298
+ std::tuple<Types...> value;
296
299
*this >> value;
297
300
return value;
298
301
}
302
+ explicit operator bool () {
303
+ return sqlite3_column_count (_binder->_stmt .get ()) >= next_index;
304
+ }
299
305
private:
300
306
database_binder *_binder;
301
307
int next_index = 0 ;
@@ -323,7 +329,6 @@ namespace sqlite {
323
329
_binder = nullptr ;
324
330
break ;
325
331
default :
326
- _binder = nullptr ;
327
332
exceptions::throw_sqlite_error (result, _binder->sql ());
328
333
}
329
334
return *this ;
You can’t perform that action at this time.
0 commit comments