Skip to content

Commit 6207b1b

Browse files
committed
fix lvalue to rvalue
1 parent 916866a commit 6207b1b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

include/cppredis/cpp_redis_request.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ namespace cpp_redis {
320320
auto tp = std::make_tuple<Args...>(std::forward<Args>(key)...);
321321

322322
std::vector<std::string> cmds;
323-
cpp_redis::unit::for_each_tuple_front(tp, [this, &cmds](std::string str, const int& index) {
323+
cpp_redis::unit::for_each_tuple_front(std::move(tp), [this, &cmds](std::string str, const int& index) {
324324
cmds.push_back(std::move(str));
325325
});
326326

include/cppredis/unit.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ namespace cpp_redis {
128128
}
129129

130130
template<typename F, typename...Ts, std::size_t...Is>
131-
void for_each_tuple_front(const std::tuple<Ts...>& tuple, F func, cpp_redis::traits::index_sequence<Is...>) {
131+
void for_each_tuple_front(std::tuple<Ts...>&& tuple, F&& func, cpp_redis::traits::index_sequence<Is...>) {
132132
constexpr auto SIZE = std::tuple_size<cpp_redis::traits::remove_reference_t<decltype(tuple)>>::value;
133133
#if (_MSC_VER >= 1700 && _MSC_VER <= 1900) //vs2012-vs2015
134134
if (constexpr(SIZE > 0)) {
@@ -155,12 +155,12 @@ namespace cpp_redis {
155155
}
156156

157157
template<typename F, typename...Ts>
158-
void for_each_tuple_front(const std::tuple<Ts...>& tuple, F&& func) {
159-
for_each_tuple_front(tuple, func, cpp_redis::traits::make_index_sequence<sizeof...(Ts)>());
158+
void for_each_tuple_front(std::tuple<Ts...>&& tuple, F&& func) {
159+
for_each_tuple_front(std::forward<std::tuple<Ts...>>(tuple), func, cpp_redis::traits::make_index_sequence<sizeof...(Ts)>());
160160
}
161161

162162
template<typename F, typename...Ts, std::size_t...Is>
163-
void for_each_tuple_back(const std::tuple<Ts...>& tuple, F func, cpp_redis::traits::index_sequence<Is...>) {
163+
void for_each_tuple_back(std::tuple<Ts...>&& tuple, F&& func, cpp_redis::traits::index_sequence<Is...>) {
164164
//匿名构造函数调用
165165
constexpr auto SIZE = std::tuple_size<cpp_redis::traits::remove_reference_t<decltype(tuple)>>::value;
166166
#if (_MSC_VER >= 1700 && _MSC_VER <= 1900) //vs2012-vs2015
@@ -181,8 +181,8 @@ namespace cpp_redis {
181181
}
182182

183183
template<typename F, typename...Ts>
184-
void for_each_tuple_back(std::tuple<Ts...>& tuple, F&& func) {
185-
for_each_tuple_back(tuple, func, cpp_redis::traits::make_index_sequence<sizeof...(Ts)>());
184+
void for_each_tuple_back(std::tuple<Ts...>&& tuple, F&& func) {
185+
for_each_tuple_back(std::forward<std::tuple<Ts...>>(tuple), func, cpp_redis::traits::make_index_sequence<sizeof...(Ts)>());
186186
}
187187
}
188188
}

0 commit comments

Comments
 (0)