Skip to content

Commit f971b71

Browse files
committed
Use universal ref and std::forward
1 parent 34b01a2 commit f971b71

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/db-copy-mgr.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ class db_copy_mgr_t
9393
* a column delimiter.
9494
*/
9595
template <typename T>
96-
void add_column(T value)
96+
void add_column(T &&value)
9797
{
98-
add_value(value);
98+
add_value(std::forward<T>(value));
9999
m_current.buffer += '\t';
100100
}
101101

src/pgsql.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class pg_conn_t
180180
* status code PGRES_COMMAND_OK or PGRES_TUPLES_OK).
181181
*/
182182
template <typename... TArgs>
183-
pg_result_t exec(fmt::format_string<TArgs...> sql, TArgs... params) const
183+
pg_result_t exec(fmt::format_string<TArgs...> sql, TArgs &&...params) const
184184
{
185185
return exec(fmt::format(sql, std::forward<TArgs>(params)...));
186186
}
@@ -196,7 +196,7 @@ class pg_conn_t
196196
*/
197197
template <typename... TArgs>
198198
void prepare(std::string const &stmt, fmt::format_string<TArgs...> sql,
199-
TArgs... params) const
199+
TArgs &&...params) const
200200
{
201201
std::string const query =
202202
fmt::format(sql, std::forward<TArgs>(params)...);
@@ -213,7 +213,7 @@ class pg_conn_t
213213
* \throws exception if the command failed.
214214
*/
215215
template <typename... TArgs>
216-
pg_result_t exec_prepared(char const *stmt, TArgs... params) const
216+
pg_result_t exec_prepared(char const *stmt, TArgs &&...params) const
217217
{
218218
return exec_prepared_with_result_format(stmt, false,
219219
std::forward<TArgs>(params)...);
@@ -229,7 +229,8 @@ class pg_conn_t
229229
* \throws exception if the command failed.
230230
*/
231231
template <typename... TArgs>
232-
pg_result_t exec_prepared_as_binary(char const *stmt, TArgs... params) const
232+
pg_result_t exec_prepared_as_binary(char const *stmt,
233+
TArgs &&...params) const
233234
{
234235
return exec_prepared_with_result_format(stmt, true,
235236
std::forward<TArgs>(params)...);
@@ -312,7 +313,7 @@ class pg_conn_t
312313
template <typename... TArgs>
313314
pg_result_t exec_prepared_with_result_format(char const *stmt,
314315
bool result_as_binary,
315-
TArgs... params) const
316+
TArgs &&...params) const
316317
{
317318
// We have to convert all non-string parameters into strings and
318319
// store them somewhere. We use the exec_params vector for this.

0 commit comments

Comments
 (0)