Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning about moved from object #3889

Merged
merged 1 commit into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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