Skip to content

Commit

Permalink
Add compile-time format string checks to format_to (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 22, 2018
1 parent c178ab4 commit ffe414c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3524,19 +3524,16 @@ inline wformat_context::iterator vformat_to(
return vformat_to<arg_formatter<range>>(buf, format_str, args);
}

template <typename... Args, std::size_t SIZE = inline_buffer_size>
template <typename String, typename... Args,
std::size_t SIZE = inline_buffer_size>
inline format_context::iterator format_to(
basic_memory_buffer<char, SIZE> &buf, string_view format_str,
basic_memory_buffer<char, SIZE> &buf, const String &format_str,
const Args & ... args) {
return vformat_to(buf, format_str, make_format_args(args...));
}

template <typename... Args, std::size_t SIZE = inline_buffer_size>
inline wformat_context::iterator format_to(
basic_memory_buffer<wchar_t, SIZE> &buf, wstring_view format_str,
const Args & ... args) {
return vformat_to(buf, format_str,
make_format_args<wformat_context>(args...));
internal::check_format_string<Args...>(format_str);
typedef typename internal::format_string_traits<String>::char_type char_t;
return vformat_to(
buf, basic_string_view<char_t>(format_str),
make_format_args<typename buffer_context<char_t>::type>(args...));
}

template <typename OutputIt, typename Char = char>
Expand Down

0 comments on commit ffe414c

Please sign in to comment.