Cleanup contexts
This commit is contained in:
parent
2595bf57b3
commit
da7a232b9e
@ -1879,11 +1879,11 @@ using basic_format_context =
|
||||
using format_context = context;
|
||||
|
||||
template <typename Char>
|
||||
using buffer_context = basic_format_context<basic_appender<Char>, Char>;
|
||||
using buffered_context = basic_format_context<basic_appender<Char>, Char>;
|
||||
|
||||
template <typename T, typename Char = char>
|
||||
using is_formattable = bool_constant<!std::is_base_of<
|
||||
detail::unformattable, decltype(detail::arg_mapper<buffer_context<Char>>()
|
||||
detail::unformattable, decltype(detail::arg_mapper<buffered_context<Char>>()
|
||||
.map(std::declval<T&>()))>::value>;
|
||||
|
||||
/**
|
||||
@ -2518,7 +2518,7 @@ template <typename T, typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx)
|
||||
-> decltype(ctx.begin()) {
|
||||
using char_type = typename ParseContext::char_type;
|
||||
using context = buffer_context<char_type>;
|
||||
using context = buffered_context<char_type>;
|
||||
using mapped_type = conditional_t<
|
||||
mapped_type_constant<T, context>::value != type::custom_type,
|
||||
decltype(arg_mapper<context>().map(std::declval<const T&>())),
|
||||
@ -2589,7 +2589,7 @@ template <typename Char, typename... Args> class format_string_checker {
|
||||
|
||||
public:
|
||||
explicit FMT_CONSTEXPR format_string_checker(basic_string_view<Char> fmt)
|
||||
: types_{mapped_type_constant<Args, buffer_context<Char>>::value...},
|
||||
: types_{mapped_type_constant<Args, buffered_context<Char>>::value...},
|
||||
context_(fmt, num_args, types_),
|
||||
parse_funcs_{&parse_format_specs<Args, parse_context_type>...} {}
|
||||
|
||||
@ -2652,16 +2652,15 @@ void check_format_string(S format_str) {
|
||||
ignore_unused(error);
|
||||
}
|
||||
|
||||
// Use vformat_args and avoid type_identity to keep symbols short and workaround
|
||||
// a GCC <= 4.8 bug.
|
||||
template <typename Char = char> struct vformat_args {
|
||||
using type =
|
||||
basic_format_args<basic_format_context<basic_appender<Char>, Char>>;
|
||||
using type = basic_format_args<buffered_context<Char>>;
|
||||
};
|
||||
template <> struct vformat_args<char> {
|
||||
using type = format_args;
|
||||
};
|
||||
|
||||
// Use vformat_args and avoid type_identity, keep symbols short and workaround
|
||||
// a GCC <= 4.8 bug.
|
||||
template <typename Char>
|
||||
void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
|
||||
typename vformat_args<Char>::type args, locale_ref loc = {});
|
||||
|
@ -441,9 +441,9 @@ template <typename T> struct styled_arg : detail::view {
|
||||
};
|
||||
|
||||
template <typename Char>
|
||||
void vformat_to(buffer<Char>& buf, const text_style& ts,
|
||||
basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
void vformat_to(
|
||||
buffer<Char>& buf, const text_style& ts, basic_string_view<Char> format_str,
|
||||
basic_format_args<buffered_context<type_identity_t<Char>>> args) {
|
||||
bool has_style = false;
|
||||
if (ts.has_emphasis()) {
|
||||
has_style = true;
|
||||
|
@ -3843,7 +3843,7 @@ FMT_CONSTEXPR auto write(OutputIt out, const T& value)
|
||||
// iterator. It's a class and not a generic lambda for compatibility with C++11.
|
||||
template <typename Char> struct default_arg_formatter {
|
||||
using iterator = basic_appender<Char>;
|
||||
using context = buffer_context<Char>;
|
||||
using context = buffered_context<Char>;
|
||||
|
||||
iterator out;
|
||||
basic_format_args<context> args;
|
||||
@ -3862,7 +3862,7 @@ template <typename Char> struct default_arg_formatter {
|
||||
|
||||
template <typename Char> struct arg_formatter {
|
||||
using iterator = basic_appender<Char>;
|
||||
using context = buffer_context<Char>;
|
||||
using context = buffered_context<Char>;
|
||||
|
||||
iterator out;
|
||||
const format_specs<Char>& specs;
|
||||
@ -4362,10 +4362,10 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
|
||||
|
||||
struct format_handler {
|
||||
basic_format_parse_context<Char> parse_context;
|
||||
buffer_context<Char> context;
|
||||
buffered_context<Char> context;
|
||||
|
||||
format_handler(basic_appender<Char> p_out, basic_string_view<Char> str,
|
||||
basic_format_args<buffer_context<Char>> p_args,
|
||||
basic_format_args<buffered_context<Char>> p_args,
|
||||
locale_ref p_loc)
|
||||
: parse_context(str), context(p_out, p_args, p_loc) {}
|
||||
|
||||
|
@ -223,7 +223,7 @@ template <typename... Args>
|
||||
void print(std::wostream& os,
|
||||
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
|
||||
Args&&... args) {
|
||||
vprint(os, fmt, fmt::make_format_args<buffer_context<wchar_t>>(args...));
|
||||
vprint(os, fmt, fmt::make_format_args<buffered_context<wchar_t>>(args...));
|
||||
}
|
||||
|
||||
FMT_EXPORT template <typename... T>
|
||||
|
@ -384,8 +384,8 @@ template <typename Context> struct range_mapper {
|
||||
|
||||
template <typename Char, typename Element>
|
||||
using range_formatter_type =
|
||||
formatter<remove_cvref_t<decltype(range_mapper<buffer_context<Char>>{}.map(
|
||||
std::declval<Element>()))>,
|
||||
formatter<remove_cvref_t<decltype(range_mapper<buffered_context<Char>>{}
|
||||
.map(std::declval<Element>()))>,
|
||||
Char>;
|
||||
|
||||
template <typename R>
|
||||
@ -462,7 +462,7 @@ struct range_formatter<
|
||||
|
||||
template <typename R, typename FormatContext>
|
||||
auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||
detail::range_mapper<buffer_context<Char>> mapper;
|
||||
detail::range_mapper<buffered_context<Char>> mapper;
|
||||
auto out = ctx.out();
|
||||
out = detail::copy_str<Char>(opening_bracket_, out);
|
||||
int i = 0;
|
||||
|
@ -65,7 +65,7 @@ FMT_BEGIN_EXPORT
|
||||
|
||||
using wstring_view = basic_string_view<wchar_t>;
|
||||
using wformat_parse_context = basic_format_parse_context<wchar_t>;
|
||||
using wformat_context = buffer_context<wchar_t>;
|
||||
using wformat_context = buffered_context<wchar_t>;
|
||||
using wformat_args = basic_format_args<wformat_context>;
|
||||
using wmemory_buffer = basic_memory_buffer<wchar_t>;
|
||||
|
||||
@ -148,7 +148,7 @@ template <typename S, typename... T,
|
||||
!std::is_same<Char, wchar_t>::value)>
|
||||
auto format(const S& format_str, T&&... args) -> std::basic_string<Char> {
|
||||
return vformat(detail::to_string_view(format_str),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
}
|
||||
|
||||
template <typename Locale, typename S,
|
||||
@ -168,7 +168,7 @@ template <typename Locale, typename S, typename... T,
|
||||
inline auto format(const Locale& loc, const S& format_str, T&&... args)
|
||||
-> std::basic_string<Char> {
|
||||
return detail::vformat(loc, detail::to_string_view(format_str),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename S,
|
||||
@ -188,7 +188,7 @@ template <typename OutputIt, typename S, typename... T,
|
||||
detail::is_exotic_char<Char>::value)>
|
||||
inline auto format_to(OutputIt out, const S& fmt, T&&... args) -> OutputIt {
|
||||
return vformat_to(out, detail::to_string_view(fmt),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
}
|
||||
|
||||
template <typename Locale, typename S, typename OutputIt, typename... Args,
|
||||
@ -214,7 +214,7 @@ inline auto format_to(OutputIt out, const Locale& loc, const S& format_str,
|
||||
T&&... args) ->
|
||||
typename std::enable_if<enable, OutputIt>::type {
|
||||
return vformat_to(out, loc, detail::to_string_view(format_str),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char, typename... Args,
|
||||
@ -237,7 +237,7 @@ template <typename OutputIt, typename S, typename... T,
|
||||
inline auto format_to_n(OutputIt out, size_t n, const S& fmt, T&&... args)
|
||||
-> format_to_n_result<OutputIt> {
|
||||
return vformat_to_n(out, n, fmt::basic_string_view<Char>(fmt),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
}
|
||||
|
||||
template <typename S, typename... T,
|
||||
@ -246,7 +246,7 @@ template <typename S, typename... T,
|
||||
inline auto formatted_size(const S& fmt, T&&... args) -> size_t {
|
||||
auto buf = detail::counting_buffer<Char>();
|
||||
detail::vformat_to(buf, detail::to_string_view(fmt),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
return buf.count();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user