Removed unnecessary changes
This commit is contained in:
parent
8c99ec0738
commit
c735a69ef8
@ -1784,20 +1784,20 @@ struct dynamic_format_specs : basic_format_specs<Char> {
|
|||||||
|
|
||||||
// Format spec handler that saves references to arguments representing dynamic
|
// Format spec handler that saves references to arguments representing dynamic
|
||||||
// width and precision to be resolved at formatting time.
|
// width and precision to be resolved at formatting time.
|
||||||
template <typename Specs, typename ParseContext>
|
template <typename ParseContext>
|
||||||
class dynamic_specs_handler
|
class dynamic_specs_handler :
|
||||||
: public specs_setter<typename ParseContext::char_type> {
|
public specs_setter<typename ParseContext::char_type> {
|
||||||
|
public:
|
||||||
public:
|
|
||||||
typedef typename ParseContext::char_type char_type;
|
typedef typename ParseContext::char_type char_type;
|
||||||
|
|
||||||
private:
|
FMT_CONSTEXPR dynamic_specs_handler(
|
||||||
typedef arg_ref<typename ParseContext::char_type> arg_ref_type;
|
dynamic_format_specs<char_type> &specs, ParseContext &ctx)
|
||||||
|
|
||||||
public:
|
|
||||||
FMT_CONSTEXPR dynamic_specs_handler(Specs &specs, ParseContext &ctx)
|
|
||||||
: specs_setter<char_type>(specs), specs_(specs), context_(ctx) {}
|
: specs_setter<char_type>(specs), specs_(specs), context_(ctx) {}
|
||||||
|
|
||||||
|
FMT_CONSTEXPR dynamic_specs_handler(const dynamic_specs_handler &other)
|
||||||
|
: specs_setter<char_type>(other),
|
||||||
|
specs_(other.specs_), context_(other.context_) {}
|
||||||
|
|
||||||
template <typename Id>
|
template <typename Id>
|
||||||
FMT_CONSTEXPR void on_dynamic_width(Id arg_id) {
|
FMT_CONSTEXPR void on_dynamic_width(Id arg_id) {
|
||||||
specs_.width_ref = make_arg_ref(arg_id);
|
specs_.width_ref = make_arg_ref(arg_id);
|
||||||
@ -1813,6 +1813,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
typedef arg_ref<char_type> arg_ref_type;
|
||||||
|
|
||||||
FMT_CONSTEXPR arg_ref_type make_arg_ref(unsigned arg_id) {
|
FMT_CONSTEXPR arg_ref_type make_arg_ref(unsigned arg_id) {
|
||||||
context_.check_arg_id(arg_id);
|
context_.check_arg_id(arg_id);
|
||||||
return arg_ref_type(arg_id);
|
return arg_ref_type(arg_id);
|
||||||
@ -1829,8 +1831,7 @@ public:
|
|||||||
return arg_ref_type(id_metadata);
|
return arg_ref_type(id_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
dynamic_format_specs<char_type> &specs_;
|
||||||
Specs &specs_;
|
|
||||||
ParseContext &context_;
|
ParseContext &context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2183,8 +2184,8 @@ struct format_type :
|
|||||||
std::integral_constant<bool, get_type<Context, T>::value != custom_type> {};
|
std::integral_constant<bool, get_type<Context, T>::value != custom_type> {};
|
||||||
|
|
||||||
template <template <typename> class Handler, typename Spec, typename Context>
|
template <template <typename> class Handler, typename Spec, typename Context>
|
||||||
void handle_dynamic_spec(Spec &value, arg_ref<typename Context::char_type> ref,
|
void handle_dynamic_spec(
|
||||||
Context &ctx) {
|
Spec &value, arg_ref<typename Context::char_type> ref, Context &ctx) {
|
||||||
typedef typename Context::char_type char_type;
|
typedef typename Context::char_type char_type;
|
||||||
typedef arg_ref<char_type> arg_ref_type;
|
typedef arg_ref<char_type> arg_ref_type;
|
||||||
switch (ref.kind) {
|
switch (ref.kind) {
|
||||||
@ -2978,8 +2979,7 @@ struct formatter<
|
|||||||
// terminating '}'.
|
// terminating '}'.
|
||||||
template <typename ParseContext>
|
template <typename ParseContext>
|
||||||
FMT_CONSTEXPR typename ParseContext::iterator parse(ParseContext &ctx) {
|
FMT_CONSTEXPR typename ParseContext::iterator parse(ParseContext &ctx) {
|
||||||
typedef internal::dynamic_specs_handler<
|
typedef internal::dynamic_specs_handler<ParseContext>
|
||||||
internal::dynamic_format_specs<Char>, ParseContext>
|
|
||||||
handler_type;
|
handler_type;
|
||||||
auto type = internal::get_type<
|
auto type = internal::get_type<
|
||||||
typename buffer_context<Char>::type, T>::value;
|
typename buffer_context<Char>::type, T>::value;
|
||||||
@ -3071,8 +3071,7 @@ class dynamic_formatter {
|
|||||||
public:
|
public:
|
||||||
template <typename ParseContext>
|
template <typename ParseContext>
|
||||||
auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
|
auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
|
||||||
typedef internal::dynamic_specs_handler<
|
typedef internal::dynamic_specs_handler<ParseContext>
|
||||||
internal::dynamic_format_specs<Char>, ParseContext>
|
|
||||||
handler_type;
|
handler_type;
|
||||||
handler_type handler(specs_, ctx);
|
handler_type handler(specs_, ctx);
|
||||||
// Checks are deferred to formatting time when the argument type is known.
|
// Checks are deferred to formatting time when the argument type is known.
|
||||||
@ -3081,26 +3080,22 @@ public:
|
|||||||
|
|
||||||
template <typename T, typename FormatContext>
|
template <typename T, typename FormatContext>
|
||||||
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out()) {
|
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out()) {
|
||||||
basic_format_specs<Char> specs;
|
|
||||||
handle_specs(ctx);
|
handle_specs(ctx);
|
||||||
specs = specs_;
|
internal::specs_checker<null_handler>
|
||||||
|
checker(null_handler(), internal::get_type<FormatContext, T>::value);
|
||||||
internal::specs_checker<null_handler> checker(
|
checker.on_align(specs_.align());
|
||||||
null_handler(), internal::get_type<FormatContext, T>::value);
|
if (specs_.flags == 0); // Do nothing.
|
||||||
checker.on_align(specs.align());
|
else if (specs_.has(SIGN_FLAG))
|
||||||
if (specs.flags == 0)
|
specs_.has(PLUS_FLAG) ? checker.on_plus() : checker.on_space();
|
||||||
; // Do nothing.
|
else if (specs_.has(MINUS_FLAG))
|
||||||
else if (specs.has(SIGN_FLAG))
|
|
||||||
specs.has(PLUS_FLAG) ? checker.on_plus() : checker.on_space();
|
|
||||||
else if (specs.has(MINUS_FLAG))
|
|
||||||
checker.on_minus();
|
checker.on_minus();
|
||||||
else if (specs.has(HASH_FLAG))
|
else if (specs_.has(HASH_FLAG))
|
||||||
checker.on_hash();
|
checker.on_hash();
|
||||||
if (specs.precision != -1)
|
if (specs_.precision != -1)
|
||||||
checker.end_precision();
|
checker.end_precision();
|
||||||
typedef output_range<typename FormatContext::iterator,
|
typedef output_range<typename FormatContext::iterator,
|
||||||
typename FormatContext::char_type> range;
|
typename FormatContext::char_type> range;
|
||||||
visit_format_arg(arg_formatter<range>(ctx, &specs),
|
visit_format_arg(arg_formatter<range>(ctx, &specs_),
|
||||||
internal::make_arg<FormatContext>(val));
|
internal::make_arg<FormatContext>(val));
|
||||||
return ctx.out();
|
return ctx.out();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,10 +170,9 @@ public:
|
|||||||
const Char *end) {
|
const Char *end) {
|
||||||
const auto specs_offset = to_unsigned(begin - format_.begin());
|
const auto specs_offset = to_unsigned(begin - format_.begin());
|
||||||
|
|
||||||
typedef internal::dynamic_format_specs<Char> prepared_specs;
|
|
||||||
typedef basic_parse_context<Char> parse_context;
|
typedef basic_parse_context<Char> parse_context;
|
||||||
prepared_specs parsed_specs;
|
internal::dynamic_format_specs<Char> parsed_specs;
|
||||||
dynamic_specs_handler<prepared_specs, parse_context> handler(
|
dynamic_specs_handler<parse_context> handler(
|
||||||
parsed_specs, parse_context_);
|
parsed_specs, parse_context_);
|
||||||
begin = parse_format_specs(begin, end, handler);
|
begin = parse_format_specs(begin, end, handler);
|
||||||
|
|
||||||
|
|||||||
@ -1217,11 +1217,9 @@ TEST(FormatTest, ConstexprSpecsHandler) {
|
|||||||
template <size_t N>
|
template <size_t N>
|
||||||
FMT_CONSTEXPR fmt::internal::dynamic_format_specs<char>
|
FMT_CONSTEXPR fmt::internal::dynamic_format_specs<char>
|
||||||
parse_dynamic_specs(const char (&s)[N]) {
|
parse_dynamic_specs(const char (&s)[N]) {
|
||||||
typedef fmt::internal::dynamic_format_specs<char> dynamic_specs;
|
fmt::internal::dynamic_format_specs<char> specs;
|
||||||
dynamic_specs specs;
|
|
||||||
test_context ctx{};
|
test_context ctx{};
|
||||||
fmt::internal::dynamic_specs_handler<dynamic_specs, test_context> h(specs,
|
fmt::internal::dynamic_specs_handler<test_context> h(specs, ctx);
|
||||||
ctx);
|
|
||||||
parse_format_specs(s, s + N, h);
|
parse_format_specs(s, s + N, h);
|
||||||
return specs;
|
return specs;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user