Allow fmt::compile to accept a fmt::basic_string_view in addition to a string literal.
This commit is contained in:
parent
50f1131fba
commit
d94558359a
@ -542,7 +542,7 @@ constexpr auto compile(S format_str) -> internal::compiled_format<S, Args...> {
|
||||
# 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 <typename... Args, typename Char, size_t N>
|
||||
auto compile(const Char (&format_str)[N])
|
||||
-> internal::compiled_format<const Char*, Args...> {
|
||||
@ -550,6 +550,13 @@ auto compile(const Char (&format_str)[N])
|
||||
basic_string_view<Char>(format_str, N - 1));
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
auto compile(const basic_string_view<Char>& format_str)
|
||||
-> internal::compiled_format<const Char*> {
|
||||
return internal::compiled_format<const Char*>(
|
||||
format_str);
|
||||
}
|
||||
|
||||
template <typename CompiledFormat, typename... Args,
|
||||
typename Char = typename CompiledFormat::char_type,
|
||||
FMT_ENABLE_IF(std::is_base_of<internal::basic_compiled_format,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user