diff --git a/include/fmt/compile.h b/include/fmt/compile.h index c68c3328..d8967d62 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -639,7 +639,7 @@ FMT_INLINE std::basic_string format(const S&, Args&&... args) { constexpr basic_string_view str = S(); if (str.size() == 2 && str[0] == '{' && str[1] == '}') - return fmt::to_string(detail::first(args...)); + return fmt::to_string(detail::first(args...)); constexpr auto compiled = detail::compile(S()); return format(compiled, std::forward(args)...); } diff --git a/include/fmt/format.h b/include/fmt/format.h index 98c15c64..93c63aba 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3481,21 +3481,23 @@ arg_join, detail::sentinel_t, wchar_t> join( std::string answer = fmt::to_string(42); \endrst */ -template ::value)> -inline std::string to_string(const T& value) { - std::string result; - detail::write(std::back_inserter(result), value); +template ::value)> +inline std::basic_string to_string(const T& value) { + std::basic_string result; + detail::write(std::back_inserter(result), value); return result; } -template ::value)> -inline std::string to_string(T value) { +template ::value)> +inline std::basic_string to_string(T value) { // The buffer should be large enough to store the number including the sign or // "false" for bool. constexpr int max_size = detail::digits10() + 2; - char buffer[max_size > 5 ? max_size : 5]; - char* begin = buffer; - return std::string(begin, detail::write(begin, value)); + Char buffer[max_size > 5 ? max_size : 5]; + Char* begin = buffer; + return std::basic_string(begin, detail::write(begin, value)); } /**