Skip to content

Commit

Permalink
🚨 fix warning about moved from object
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Dec 18, 2022
1 parent 7f72eed commit bef2e56
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions include/nlohmann/detail/string_concat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ inline std::size_t concat_length()
}

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

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

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

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

template<typename StringType, typename... Args>
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
inline std::size_t concat_length(const StringType& str, const Args& ... rest)
{
return str.size() + concat_length(std::forward<Args>(rest)...);
return str.size() + concat_length(rest...);
}

template<typename OutStringType>
Expand Down Expand Up @@ -137,7 +137,7 @@ template<typename OutStringType = std::string, typename... Args>
inline OutStringType concat(Args && ... args)
{
OutStringType str;
str.reserve(concat_length(std::forward<Args>(args)...));
str.reserve(concat_length(args...));
concat_into(str, std::forward<Args>(args)...);
return str;
}
Expand Down
18 changes: 9 additions & 9 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4169,28 +4169,28 @@ inline std::size_t concat_length()
}

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

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

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

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

template<typename StringType, typename... Args>
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
inline std::size_t concat_length(const StringType& str, const Args& ... rest)
{
return str.size() + concat_length(std::forward<Args>(rest)...);
return str.size() + concat_length(rest...);
}

template<typename OutStringType>
Expand Down Expand Up @@ -4281,7 +4281,7 @@ template<typename OutStringType = std::string, typename... Args>
inline OutStringType concat(Args && ... args)
{
OutStringType str;
str.reserve(concat_length(std::forward<Args>(args)...));
str.reserve(concat_length(args...));
concat_into(str, std::forward<Args>(args)...);
return str;
}
Expand Down

0 comments on commit bef2e56

Please sign in to comment.