Skip to content

Commit 1dcff42

Browse files
committed
Add overload for format_to_n supporting non-char and non-wchar_t output iterators
1 parent c138aa2 commit 1dcff42

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/fmt/xchar.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,17 @@ FMT_INLINE auto format_to_n(OutputIt out, size_t n, wformat_string<T...> fmt,
286286
return vformat_to_n(out, n, fmt.get(), fmt::make_wformat_args(args...));
287287
}
288288

289+
template <typename OutputIt, typename S, typename... T,
290+
typename Char = detail::format_string_char_t<S>,
291+
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value &&
292+
!std::is_same<Char, char>::value &&
293+
!std::is_same<Char, wchar_t>::value)>
294+
inline auto format_to_n(OutputIt out, size_t n, const S& fmt, T&&... args)
295+
-> format_to_n_result<OutputIt> {
296+
return vformat_to_n(out, n, fmt::basic_string_view<Char>(fmt),
297+
fmt::make_format_args<buffered_context<Char>>(args...));
298+
}
299+
289300
template <typename S, typename... T,
290301
typename Char = detail::format_string_char_t<S>,
291302
FMT_ENABLE_IF(detail::is_exotic_char<Char>::value)>

0 commit comments

Comments
 (0)