diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 7042d2b8..bdf93013 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -33,11 +33,9 @@ namespace detail { FMT_FUNC void assert_fail(const char* file, int line, const char* message) { // Use unchecked std::fprintf to avoid triggering another assertion when - // writing to stderr fails - std::fprintf(stderr, "%s:%d: assertion failed: %s", file, line, message); - // Chosen instead of std::abort to satisfy Clang in CUDA mode during device - // code pass. - std::terminate(); + // writing to stderr fails. + fprintf(stderr, "%s:%d: assertion failed: %s", file, line, message); + abort(); } FMT_FUNC void format_error_code(detail::buffer& out, int error_code, diff --git a/include/fmt/format.h b/include/fmt/format.h index 911628e8..9533c97c 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3868,17 +3868,14 @@ template void vformat_to(buffer& buf, basic_string_view fmt, typename vformat_args::type args, locale_ref loc = {}) { auto out = basic_appender(buf); - if (fmt.size() == 2 && equal2(fmt.data(), "{}")) - return args.get(0).visit(default_arg_formatter{out}); parse_format_string( fmt, format_handler{parse_context(fmt), {out, args, loc}}); } -template -auto vformat(const Locale& loc, basic_string_view fmt, - typename detail::vformat_args::type args) - -> std::basic_string { - auto buf = basic_memory_buffer(); +template +auto vformat(const Locale& loc, string_view fmt, format_args args) + -> std::string { + auto buf = memory_buffer(); detail::vformat_to(buf, fmt, args, detail::locale_ref(loc)); return {buf.data(), buf.size()}; } diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index 553e9d30..3d928a45 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -197,10 +197,13 @@ template , FMT_ENABLE_IF(detail::is_locale::value&& detail::is_exotic_char::value)> -inline auto vformat(const Locale& loc, const S& format_str, +inline auto vformat(const Locale& loc, const S& fmt, typename detail::vformat_args::type args) -> std::basic_string { - return detail::vformat(loc, detail::to_string_view(format_str), args); + auto buf = basic_memory_buffer(); + detail::vformat_to(buf, detail::to_string_view(fmt), args, + detail::locale_ref(loc)); + return {buf.data(), buf.size()}; } template ::value)> inline auto format(const Locale& loc, const S& format_str, T&&... args) -> std::basic_string { - return detail::vformat( - loc, detail::to_string_view(format_str), - fmt::make_format_args>(args...)); + return vformat(loc, detail::to_string_view(format_str), + fmt::make_format_args>(args...)); } template