From 431d0f85cfd12cc9b0ce6564125b379cd6616edb Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Sat, 27 Jul 2019 17:56:34 -0400 Subject: [PATCH] Use basic_string_view in non-template UDL --- include/fmt/format.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 750677d0..628d68d6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3466,7 +3466,7 @@ template class udl_formatter { }; # else template struct udl_formatter { - const Char* str; + basic_string_view str; template auto operator()(Args&&... args) const @@ -3477,7 +3477,7 @@ template struct udl_formatter { # endif // FMT_USE_UDL_TEMPLATE template struct udl_arg { - const Char* str; + basic_string_view str; template named_arg operator=(T&& value) const { return {str, std::forward(value)}; @@ -3508,13 +3508,13 @@ FMT_CONSTEXPR internal::udl_formatter operator""_format() { std::string message = "The answer is {}"_format(42); \endrst */ -inline internal::udl_formatter operator"" _format(const char* s, - std::size_t) { - return {s}; +FMT_CONSTEXPR internal::udl_formatter operator"" _format(const char* s, + std::size_t n) { + return {{s, n}}; } -inline internal::udl_formatter operator"" _format(const wchar_t* s, - std::size_t) { - return {s}; +FMT_CONSTEXPR internal::udl_formatter operator"" _format( + const wchar_t* s, std::size_t n) { + return {{s, n}}; } # endif // FMT_USE_UDL_TEMPLATE