From d94558359a6068e67730c199ea9f65980d42c4ab Mon Sep 17 00:00:00 2001 From: Dair Grant Date: Sat, 7 Mar 2020 00:17:25 +0000 Subject: [PATCH] Allow fmt::compile to accept a fmt::basic_string_view in addition to a string literal. --- include/fmt/compile.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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