diff --git a/include/LightGBM/utils/common.h b/include/LightGBM/utils/common.h index c0d8a762058f..d11f77253042 100644 --- a/include/LightGBM/utils/common.h +++ b/include/LightGBM/utils/common.h @@ -1201,8 +1201,8 @@ inline static std::vector StringToArray(const std::string& str, char delimite * /Users/jlamb/repos/LightGBM/include/LightGBM/utils/common.h:1203:35: error: 'format' is not a constant expression */ template -inline static void format_to_buf(char* buffer, const size_t buf_len, const char* format, const T value) { - const auto result = fmt::format_to_n(buffer, buf_len, format, value); +inline static void format_to_buf(char* buffer, const size_t buf_len, fmt::format_string format, const T value) { + auto result = fmt::format_to_n(buffer, buf_len, format, value); if (result.size >= buf_len) { Log::Fatal("Numerical conversion failed. Buffer is too small."); } @@ -1212,21 +1212,21 @@ inline static void format_to_buf(char* buffer, const size_t buf_len, const char* template struct __TToStringHelper { void operator()(T value, char* buffer, size_t buf_len) const { - format_to_buf(buffer, buf_len, "{}", value); + format_to_buf(buffer, buf_len, fmt::format_string("{}"), value); } }; template struct __TToStringHelper { void operator()(T value, char* buffer, size_t buf_len) const { - format_to_buf(buffer, buf_len, "{:g}", value); + format_to_buf(buffer, buf_len, fmt::format_string("{:g}"), value); } }; template struct __TToStringHelper { void operator()(T value, char* buffer, size_t buf_len) const { - format_to_buf(buffer, buf_len, "{:.17g}", value); + format_to_buf(buffer, buf_len, fmt::format_string("{:.17g}"), value); } }; @@ -1234,7 +1234,7 @@ struct __TToStringHelper { * Converts an array to a string with with values separated by the space character. * This method replaces Common's ``ArrayToString`` and ``ArrayToStringFast`` functionality * and is locale-independent. -* +* * \note If ``high_precision_output`` is set to true, * floating point values are output with more digits of precision. */