diff --git a/include/fmt/compile.h b/include/fmt/compile.h index e4b12f34..0bb8cb5a 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -542,7 +542,7 @@ constexpr auto compile(S format_str) -> internal::compiled_format { # endif // __cpp_if_constexpr #endif // FMT_USE_CONSTEXPR -// Compiles the format string which must be a string literal. +// Compiles the format string which must be a string literal or view. template auto compile(const Char (&format_str)[N]) -> internal::compiled_format { @@ -550,6 +550,13 @@ auto compile(const Char (&format_str)[N]) basic_string_view(format_str, N - 1)); } +template +auto compile(const basic_string_view& format_str) + -> internal::compiled_format { + return internal::compiled_format( + format_str); +} + template