From 273592b6ba39babe6407021ffc089bfe7328e447 Mon Sep 17 00:00:00 2001 From: alexliyu7352 Date: Mon, 9 Oct 2023 16:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96str=5Fformat=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 没必要兼容c++20,毕竟format不同,c++20以上自己使用std::vformat或者std::format (#184) --- src/Util/util.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Util/util.h b/src/Util/util.h index b2b0c7a32..14c1ee83f 100644 --- a/src/Util/util.h +++ b/src/Util/util.h @@ -223,9 +223,7 @@ bool end_with(const std::string &str, const std::string &substr); //拼接格式字符串 template std::string str_format(const std::string &format, Args... args) { -#if __cplusplus > 202002L - return std::format(format, args...); -#else + // Calculate the buffer size auto size_buf = snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Allocate the buffer @@ -244,7 +242,6 @@ std::string str_format(const std::string &format, Args... args) { auto result = snprintf(buf.get(), size_buf, format.c_str(), args ...); // Return the formatted string return std::string(buf.get(), buf.get() + result); -#endif } #ifndef bzero