Make format_to a non-member

This commit is contained in:
Victor Zverovich
2019-08-03 08:36:53 -07:00
parent 3df0ea34e5
commit a5bd3ddb28
4 changed files with 24 additions and 24 deletions
+11 -8
View File
@@ -185,14 +185,6 @@ class prepared_format {
prepared_format() = delete;
template <typename OutputIt>
inline OutputIt format_to(OutputIt out, const Args&... args) const {
typedef format_context_t<OutputIt, char_type> context;
typedef output_range<OutputIt, char_type> range;
format_arg_store<context, Args...> as(args...);
return this->vformat_to(range(out), basic_format_args<context>(as));
}
typedef buffer_context<char_type> context;
template <typename Range, typename Context>
@@ -682,6 +674,17 @@ std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
return to_string(buffer);
}
template <typename OutputIt, typename CompiledFormat, typename... Args>
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
const Args&... args) {
using char_type = typename CompiledFormat::char_type;
using range = internal::output_range<OutputIt, char_type>;
using context = format_context_t<OutputIt, char_type>;
format_arg_store<context, Args...> as(args...);
return cf.template vformat_to<range, context>(
range(out), {make_format_args<context>(args...)});
}
template <typename OutputIt, typename CompiledFormat, typename... Args,
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)>
format_to_n_result<OutputIt> format_to_n(OutputIt out, unsigned n,