(w)context -> (w)format_context

This commit is contained in:
Victor Zverovich
2018-04-08 07:03:44 -07:00
parent 26aa34f319
commit fd0b07a75a
9 changed files with 44 additions and 41 deletions

View File

@@ -911,8 +911,8 @@ struct buffer_context {
typedef basic_format_context<
std::back_insert_iterator<internal::basic_buffer<Char>>, Char> type;
};
typedef buffer_context<char>::type context;
typedef buffer_context<wchar_t>::type wcontext;
typedef buffer_context<char>::type format_context;
typedef buffer_context<wchar_t>::type wformat_context;
namespace internal {
template <typename Context, typename T>
@@ -1008,8 +1008,9 @@ inline format_arg_store<Context, Args...> make_args(const Args & ... args) {
}
template <typename ...Args>
inline format_arg_store<context, Args...> make_args(const Args & ... args) {
return format_arg_store<context, Args...>(args...);
inline format_arg_store<format_context, Args...>
make_args(const Args & ... args) {
return format_arg_store<format_context, Args...>(args...);
}
/** Formatting arguments. */
@@ -1093,12 +1094,12 @@ class basic_format_args {
/** An alias to ``basic_format_args<context>``. */
// It is a separate type rather than a typedef to make symbols readable.
struct format_args: basic_format_args<context> {
struct format_args: basic_format_args<format_context> {
template <typename ...Args>
format_args(Args && ... arg)
: basic_format_args<context>(std::forward<Args>(arg)...) {}
: basic_format_args<format_context>(std::forward<Args>(arg)...) {}
};
typedef basic_format_args<wcontext> wformat_args;
typedef basic_format_args<wformat_context> wformat_args;
namespace internal {
template <typename Char>
@@ -1106,7 +1107,7 @@ struct named_arg_base {
basic_string_view<Char> name;
// Serialized value<context>.
mutable char data[sizeof(basic_format_arg<context>)];
mutable char data[sizeof(basic_format_arg<format_context>)];
named_arg_base(basic_string_view<Char> nm) : name(nm) {}
@@ -1167,10 +1168,10 @@ inline void print_colored(color c, string_view format_str,
vprint_colored(c, format_str, make_args(args...));
}
context::iterator vformat_to(internal::buffer &buf, string_view format_str,
format_args args);
wcontext::iterator vformat_to(internal::wbuffer &buf, wstring_view format_str,
wformat_args args);
format_context::iterator vformat_to(
internal::buffer &buf, string_view format_str, format_args args);
wformat_context::iterator vformat_to(
internal::wbuffer &buf, wstring_view format_str, wformat_args args);
template <typename Container>
struct is_contiguous : std::false_type {};
@@ -1211,12 +1212,12 @@ inline std::string format(string_view format_str, const Args & ... args) {
// This should be just
// return vformat(format_str, make_args(args...));
// but gcc has trouble optimizing the latter, so break it down.
format_arg_store<context, Args...> as(args...);
format_arg_store<format_context, Args...> as(args...);
return vformat(format_str, as);
}
template <typename... Args>
inline std::wstring format(wstring_view format_str, const Args & ... args) {
format_arg_store<wcontext, Args...> as(args...);
format_arg_store<wformat_context, Args...> as(args...);
return vformat(format_str, as);
}
@@ -1233,7 +1234,7 @@ FMT_API void vprint(std::FILE *f, string_view format_str, format_args args);
*/
template <typename... Args>
inline void print(std::FILE *f, string_view format_str, const Args & ... args) {
format_arg_store<context, Args...> as(args...);
format_arg_store<format_context, Args...> as(args...);
vprint(f, format_str, as);
}
@@ -1250,7 +1251,7 @@ FMT_API void vprint(string_view format_str, format_args args);
*/
template <typename... Args>
inline void print(string_view format_str, const Args & ... args) {
format_arg_store<context, Args...> as(args...);
format_arg_store<format_context, Args...> as(args...);
vprint(format_str, as);
}
} // namespace fmt

View File

@@ -3368,28 +3368,28 @@ std::basic_string<Char> to_string(const basic_memory_buffer<Char> &buffer) {
return std::basic_string<Char>(buffer.data(), buffer.size());
}
inline context::iterator vformat_to(
inline format_context::iterator vformat_to(
internal::buffer &buf, string_view format_str, format_args args) {
typedef back_insert_range<internal::buffer> range;
return vformat_to<arg_formatter<range>>(buf, format_str, args);
}
inline wcontext::iterator vformat_to(
inline wformat_context::iterator vformat_to(
internal::wbuffer &buf, wstring_view format_str, wformat_args args) {
typedef back_insert_range<internal::wbuffer> range;
return vformat_to<arg_formatter<range>>(buf, format_str, args);
}
template <typename... Args>
inline context::iterator format_to(
inline format_context::iterator format_to(
memory_buffer &buf, string_view format_str, const Args & ... args) {
return vformat_to(buf, format_str, make_args(args...));
}
template <typename... Args>
inline wcontext::iterator format_to(
inline wformat_context::iterator format_to(
wmemory_buffer &buf, wstring_view format_str, const Args & ... args) {
return vformat_to(buf, format_str, make_args<wcontext>(args...));
return vformat_to(buf, format_str, make_args<wformat_context>(args...));
}
template <typename OutputIt, typename Char = char>

View File

@@ -110,7 +110,7 @@ struct formatter<std::tm> {
return pointer_from(end);
}
auto format(const std::tm &tm, context &ctx) -> decltype(ctx.begin()) {
auto format(const std::tm &tm, format_context &ctx) -> decltype(ctx.begin()) {
internal::buffer &buf = internal::get_container(ctx.begin());
std::size_t start = buf.size();
for (;;) {