@@ -204,17 +204,17 @@ namespace sqnice {
204
204
}
205
205
206
206
template <bindable T>
207
- status bind (int idx, T& & v) {
208
- return bind_helper (*this , idx, std::forward<T>(v) );
207
+ status bind (int idx, T const & v) {
208
+ return bind_helper (*this , idx, v );
209
209
}
210
210
211
211
using pointer_destructor = void (*)(void *);
212
212
status bind_pointer (int idx, void * pointer, const char * type, pointer_destructor);
213
213
214
214
// / Binds a value to a named parameter.
215
215
template <typename T>
216
- status bind (char const * name, T& & v) {
217
- return bind (check_parameter_index (name), std::forward<T>(v) );
216
+ status bind (char const * name, T const & v) {
217
+ return bind (check_parameter_index (name), v );
218
218
}
219
219
220
220
sqlite3_stmt* stmt () const ;
@@ -263,8 +263,8 @@ namespace sqnice {
263
263
status bind_blob (int idx, blob value, bool copy);
264
264
265
265
template <typename T, typename ... Args>
266
- void _bind_args (int idx, T&& arg, Args... rest) {
267
- bind (idx, std::forward<T>( arg) );
266
+ void _bind_args (int idx, T const & arg, Args& ... rest) {
267
+ bind (idx, arg);
268
268
if constexpr (sizeof ...(rest) > 0 )
269
269
_bind_args (idx + 1 , rest...);
270
270
}
@@ -280,7 +280,7 @@ namespace sqnice {
280
280
// / Assigning a value to a `bindref` calls `bind` on the `statement`.
281
281
// / @note This returns `status`, not `*this`, which is unusual for an assignment operator.
282
282
template <class T >
283
- status operator = (T&& value) {return stmt_.bind (idx_, std::forward<T>( value) );}
283
+ status operator = (T const & value) {return stmt_.bind (idx_, value);}
284
284
285
285
private:
286
286
friend class statement ;
@@ -296,7 +296,7 @@ namespace sqnice {
296
296
class statement ::bindstream {
297
297
public:
298
298
template <class T >
299
- bindstream& operator << (T&& v ) {stmt_.bind (idx_++, std::forward<T>(v) ); return *this ;}
299
+ bindstream& operator << (T const & value ) {stmt_.bind (idx_++, value ); return *this ;}
300
300
301
301
private:
302
302
friend class statement ;
@@ -326,12 +326,12 @@ namespace sqnice {
326
326
327
327
// / Binds parameters to the arguments, then executes the statement.
328
328
template <typename ... Args>
329
- status execute (Args... args) {_bind_args (1 , args...); return execute ();}
329
+ status execute (Args& ... args) {_bind_args (1 , args...); return execute ();}
330
330
331
331
// / Binds parameters to the arguments, then executes the statement,
332
332
// / but without throwing exceptions.
333
333
template <typename ... Args>
334
- [[nodiscard]] status try_execute (Args... args) noexcept {
334
+ [[nodiscard]] status try_execute (Args& ... args) noexcept {
335
335
_bind_args (1 ,args...);
336
336
return try_execute ();
337
337
}
@@ -358,10 +358,10 @@ namespace sqnice {
358
358
359
359
// / Binds its arguments to multiple query parameters starting at index 1.
360
360
template <typename ... Args>
361
- query& operator () (Args... args) & {_bind_args (1 , args...); return *this ;}
361
+ query& operator () (Args& ... args) & {_bind_args (1 , args...); return *this ;}
362
362
363
363
template <typename ... Args>
364
- [[nodiscard]] query operator () (Args... args) && { // (variant avoids dangling ref to
364
+ [[nodiscard]] query operator () (Args& ... args) && { // (variant avoids dangling ref to
365
365
_bind_args (1 , args...); return std::move (*this ); // rvalue by returning a copy)
366
366
}
367
367
0 commit comments