diff --git a/include/fmt/format.h b/include/fmt/format.h index f3ea2043..095b7a71 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3175,6 +3175,14 @@ struct format_handler : detail::error_handler { basic_format_arg arg; }; +template +bool equal2(const Char* lhs, const char* rhs) { + return lhs[0] == rhs[0] && lhs[1] == rhs[1]; +} +inline bool equal2(const char* lhs, const char* rhs) { + return memcmp(lhs, rhs, 2) == 0; +} + /** Formats arguments and writes the output to the range. */ template typename Context::iterator vformat_to( @@ -3182,7 +3190,7 @@ typename Context::iterator vformat_to( basic_format_args args, detail::locale_ref loc = detail::locale_ref()) { format_handler h(out, format_str, args, loc); - if (format_str.size() == 2 && format_str[0] == '{' && format_str[1] == '}') { + if (format_str.size() == 2 && equal2(format_str.data(), "{}")) { auto arg = detail::get_arg(h.context, 0); h.parse_context.advance_to(&format_str[1]); return visit_format_arg(ArgFormatter(h.context, &h.parse_context), arg);