From ffe414cad13d66c7dcefa412d41f377c9635b80c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 22 Jul 2018 15:30:51 -0700 Subject: [PATCH] Add compile-time format string checks to format_to (#783) --- include/fmt/format.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index d827306a..fcb13a25 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3524,19 +3524,16 @@ inline wformat_context::iterator vformat_to( return vformat_to>(buf, format_str, args); } -template +template inline format_context::iterator format_to( - basic_memory_buffer &buf, string_view format_str, + basic_memory_buffer &buf, const String &format_str, const Args & ... args) { - return vformat_to(buf, format_str, make_format_args(args...)); -} - -template -inline wformat_context::iterator format_to( - basic_memory_buffer &buf, wstring_view format_str, - const Args & ... args) { - return vformat_to(buf, format_str, - make_format_args(args...)); + internal::check_format_string(format_str); + typedef typename internal::format_string_traits::char_type char_t; + return vformat_to( + buf, basic_string_view(format_str), + make_format_args::type>(args...)); } template