mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
fix(format): Poco::format and C++20 #3733
This commit is contained in:
@@ -106,20 +106,26 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
|
||||
/// std::string s2 = format("second: %[1]d, first: %[0]d", 1, 2);
|
||||
|
||||
void Foundation_API format(std::string& result, const char *fmt, const std::vector<Any>& values);
|
||||
/// Supports a variable number of arguments and is used by
|
||||
/// all other variants of format().
|
||||
/// Supports a variable number of arguments.
|
||||
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
|
||||
/// Supports a variable number of arguments.
|
||||
|
||||
inline void formatAny(std::string& result, const std::string& fmt, const std::vector<Any>& values)
|
||||
/// Supports a variable number of arguments and is used by
|
||||
/// all other variants of format().
|
||||
{
|
||||
format(result, fmt, values);
|
||||
}
|
||||
|
||||
inline void formatAny(std::string& result, const char *fmt, const std::vector<Any>& values)
|
||||
/// Supports a variable number of arguments and is used by
|
||||
/// all other variants of format().
|
||||
{
|
||||
format(result, fmt, values);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
#ifdef __cpp_lib_remove_cvref
|
||||
typename std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>, std::vector<Any>>>,
|
||||
#endif
|
||||
typename... Args>
|
||||
template <typename T, typename... Args>
|
||||
void format(std::string& result, const std::string& fmt, T arg1, Args... args)
|
||||
/// Appends the formatted string to result.
|
||||
{
|
||||
@@ -127,16 +133,11 @@ void format(std::string& result, const std::string& fmt, T arg1, Args... args)
|
||||
values.reserve(sizeof...(Args) + 1);
|
||||
values.emplace_back(arg1);
|
||||
values.insert(values.end(), { args... });
|
||||
format(result, fmt, values);
|
||||
formatAny(result, fmt, values);
|
||||
}
|
||||
|
||||
|
||||
template <
|
||||
typename T,
|
||||
#ifdef __cpp_lib_remove_cvref
|
||||
typename std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>, std::vector<Any>>>,
|
||||
#endif
|
||||
typename... Args>
|
||||
template <typename T, typename... Args>
|
||||
void format(std::string& result, const char* fmt, T arg1, Args... args)
|
||||
/// Appends the formatted string to result.
|
||||
{
|
||||
@@ -144,16 +145,11 @@ void format(std::string& result, const char* fmt, T arg1, Args... args)
|
||||
values.reserve(sizeof...(Args) + 1);
|
||||
values.emplace_back(arg1);
|
||||
values.insert(values.end(), { args... });
|
||||
format(result, fmt, values);
|
||||
formatAny(result, fmt, values);
|
||||
}
|
||||
|
||||
|
||||
template <
|
||||
typename T,
|
||||
#ifdef __cpp_lib_remove_cvref
|
||||
typename std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>, std::vector<Any>>>,
|
||||
#endif
|
||||
typename... Args>
|
||||
template <typename T, typename... Args>
|
||||
std::string format(const std::string& fmt, T arg1, Args... args)
|
||||
/// Returns the formatted string.
|
||||
{
|
||||
@@ -162,17 +158,12 @@ std::string format(const std::string& fmt, T arg1, Args... args)
|
||||
values.emplace_back(arg1);
|
||||
values.insert(values.end(), { args... });
|
||||
std::string result;
|
||||
format(result, fmt, values);
|
||||
formatAny(result, fmt, values);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <
|
||||
typename T,
|
||||
#ifdef __cpp_lib_remove_cvref
|
||||
typename std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>, std::vector<Any>>>,
|
||||
#endif
|
||||
typename... Args>
|
||||
template <typename T, typename... Args>
|
||||
std::string format(const char* fmt, T arg1, Args... args)
|
||||
/// Returns the formatted string.
|
||||
{
|
||||
@@ -181,7 +172,7 @@ std::string format(const char* fmt, T arg1, Args... args)
|
||||
values.emplace_back(arg1);
|
||||
values.insert(values.end(), { args... });
|
||||
std::string result;
|
||||
format(result, fmt, values);
|
||||
formatAny(result, fmt, values);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user