diff --git a/include/fmt/core.h b/include/fmt/core.h index 83adfe2a..73974a74 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -681,12 +681,14 @@ template class basic_format_parse_context { constexpr bool starts_with(iterator prefix) const noexcept { auto first = begin(); auto last = end(); + bool mismatch_found = false; while (first != last && *prefix != '\0') { if (*prefix++ != *first++) { - return false; + mismatch_found = true; + break; } } - return *prefix == '\0'; + return !mismatch_found && *prefix == '\0'; } /** Advances the begin iterator to ``it``. */