Skip to content

Commit 80dfb04

Browse files
authored
Fix warning about moved from object (#3889)
1 parent 2ca8dab commit 80dfb04

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

include/nlohmann/detail/string_concat.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ inline std::size_t concat_length()
2525
}
2626

2727
template<typename... Args>
28-
inline std::size_t concat_length(const char* cstr, Args&& ... rest);
28+
inline std::size_t concat_length(const char* cstr, const Args& ... rest);
2929

3030
template<typename StringType, typename... Args>
31-
inline std::size_t concat_length(const StringType& str, Args&& ... rest);
31+
inline std::size_t concat_length(const StringType& str, const Args& ... rest);
3232

3333
template<typename... Args>
34-
inline std::size_t concat_length(const char /*c*/, Args&& ... rest)
34+
inline std::size_t concat_length(const char /*c*/, const Args& ... rest)
3535
{
36-
return 1 + concat_length(std::forward<Args>(rest)...);
36+
return 1 + concat_length(rest...);
3737
}
3838

3939
template<typename... Args>
40-
inline std::size_t concat_length(const char* cstr, Args&& ... rest)
40+
inline std::size_t concat_length(const char* cstr, const Args& ... rest)
4141
{
4242
// cppcheck-suppress ignoredReturnValue
43-
return ::strlen(cstr) + concat_length(std::forward<Args>(rest)...);
43+
return ::strlen(cstr) + concat_length(rest...);
4444
}
4545

4646
template<typename StringType, typename... Args>
47-
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
47+
inline std::size_t concat_length(const StringType& str, const Args& ... rest)
4848
{
49-
return str.size() + concat_length(std::forward<Args>(rest)...);
49+
return str.size() + concat_length(rest...);
5050
}
5151

5252
template<typename OutStringType>
@@ -137,7 +137,7 @@ template<typename OutStringType = std::string, typename... Args>
137137
inline OutStringType concat(Args && ... args)
138138
{
139139
OutStringType str;
140-
str.reserve(concat_length(std::forward<Args>(args)...));
140+
str.reserve(concat_length(args...));
141141
concat_into(str, std::forward<Args>(args)...);
142142
return str;
143143
}

single_include/nlohmann/json.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -4169,28 +4169,28 @@ inline std::size_t concat_length()
41694169
}
41704170

41714171
template<typename... Args>
4172-
inline std::size_t concat_length(const char* cstr, Args&& ... rest);
4172+
inline std::size_t concat_length(const char* cstr, const Args& ... rest);
41734173

41744174
template<typename StringType, typename... Args>
4175-
inline std::size_t concat_length(const StringType& str, Args&& ... rest);
4175+
inline std::size_t concat_length(const StringType& str, const Args& ... rest);
41764176

41774177
template<typename... Args>
4178-
inline std::size_t concat_length(const char /*c*/, Args&& ... rest)
4178+
inline std::size_t concat_length(const char /*c*/, const Args& ... rest)
41794179
{
4180-
return 1 + concat_length(std::forward<Args>(rest)...);
4180+
return 1 + concat_length(rest...);
41814181
}
41824182

41834183
template<typename... Args>
4184-
inline std::size_t concat_length(const char* cstr, Args&& ... rest)
4184+
inline std::size_t concat_length(const char* cstr, const Args& ... rest)
41854185
{
41864186
// cppcheck-suppress ignoredReturnValue
4187-
return ::strlen(cstr) + concat_length(std::forward<Args>(rest)...);
4187+
return ::strlen(cstr) + concat_length(rest...);
41884188
}
41894189

41904190
template<typename StringType, typename... Args>
4191-
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
4191+
inline std::size_t concat_length(const StringType& str, const Args& ... rest)
41924192
{
4193-
return str.size() + concat_length(std::forward<Args>(rest)...);
4193+
return str.size() + concat_length(rest...);
41944194
}
41954195

41964196
template<typename OutStringType>
@@ -4281,7 +4281,7 @@ template<typename OutStringType = std::string, typename... Args>
42814281
inline OutStringType concat(Args && ... args)
42824282
{
42834283
OutStringType str;
4284-
str.reserve(concat_length(std::forward<Args>(args)...));
4284+
str.reserve(concat_length(args...));
42854285
concat_into(str, std::forward<Args>(args)...);
42864286
return str;
42874287
}

0 commit comments

Comments
 (0)