Commit 466128de authored by Victor Zverovich's avatar Victor Zverovich

Remove unused code and refactor

parent 22e98a5b
......@@ -805,10 +805,10 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
auto out = std::back_inserter(buf);
using range = internal::output_range<decltype(ctx.out()), Char>;
internal::basic_writer<range> w(range(ctx.out()));
internal::handle_dynamic_spec<internal::width_checker>(
specs.width, width_ref, ctx, format_str.begin());
internal::handle_dynamic_spec<internal::width_checker>(specs.width,
width_ref, ctx);
internal::handle_dynamic_spec<internal::precision_checker>(
precision, precision_ref, ctx, format_str.begin());
precision, precision_ref, ctx);
if (begin == end || *begin == '}') {
out = internal::format_chrono_duration_value(out, d.count(), precision);
internal::format_chrono_duration_unit<Period>(out);
......
This diff is collapsed.
......@@ -2556,8 +2556,7 @@ void check_format_string(S format_str) {
template <template <typename> class Handler, typename Spec, typename Context>
void handle_dynamic_spec(Spec& value, arg_ref<typename Context::char_type> ref,
Context& ctx,
const typename Context::char_type* format_str) {
Context& ctx) {
switch (ref.kind) {
case arg_id_kind::none:
break;
......@@ -2935,13 +2934,12 @@ template <typename T, typename Char>
struct formatter<T, Char,
enable_if_t<internal::type_constant<T, Char>::value !=
internal::custom_type>> {
FMT_CONSTEXPR formatter() : format_str_(nullptr) {}
FMT_CONSTEXPR formatter() {}
// Parses format specifiers stopping either at the end of the range or at the
// terminating '}'.
template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
format_str_ = ctx.begin();
using handler_type = internal::dynamic_specs_handler<ParseContext>;
auto type = internal::type_constant<T, Char>::value;
internal::specs_checker<handler_type> handler(handler_type(specs_, ctx),
......@@ -2991,9 +2989,9 @@ struct formatter<T, Char,
template <typename FormatContext>
auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) {
internal::handle_dynamic_spec<internal::width_checker>(
specs_.width, specs_.width_ref, ctx, format_str_);
specs_.width, specs_.width_ref, ctx);
internal::handle_dynamic_spec<internal::precision_checker>(
specs_.precision, specs_.precision_ref, ctx, format_str_);
specs_.precision, specs_.precision_ref, ctx);
using range_type =
internal::output_range<typename FormatContext::iterator,
typename FormatContext::char_type>;
......@@ -3003,7 +3001,6 @@ struct formatter<T, Char,
private:
internal::dynamic_format_specs<Char> specs_;
const Char* format_str_;
};
#define FMT_FORMAT_AS(Type, Base) \
......@@ -3104,9 +3101,9 @@ template <typename Char = char> class dynamic_formatter {
private:
template <typename Context> void handle_specs(Context& ctx) {
internal::handle_dynamic_spec<internal::width_checker>(
specs_.width, specs_.width_ref, ctx, format_str_);
specs_.width, specs_.width_ref, ctx);
internal::handle_dynamic_spec<internal::precision_checker>(
specs_.precision, specs_.precision_ref, ctx, format_str_);
specs_.precision, specs_.precision_ref, ctx);
}
internal::dynamic_format_specs<Char> specs_;
......
......@@ -67,40 +67,6 @@ TEST(CompileTest, CompileTimePreparedPartsTypeProvider) {
}
#endif
class custom_parts_container {
public:
typedef fmt::internal::format_part<char> format_part_type;
private:
typedef std::deque<format_part_type> parts;
public:
void add(format_part_type part) { parts_.push_back(std::move(part)); }
void substitute_last(format_part_type part) {
parts_.back() = std::move(part);
}
format_part_type last() { return parts_.back(); }
auto begin() -> decltype(std::declval<parts>().begin()) {
return parts_.begin();
}
auto begin() const -> decltype(std::declval<const parts>().begin()) {
return parts_.begin();
}
auto end() -> decltype(std::declval<parts>().begin()) { return parts_.end(); }
auto end() const -> decltype(std::declval<const parts>().begin()) {
return parts_.end();
}
private:
parts parts_;
};
TEST(CompileTest, PassStringLiteralFormat) {
const auto prepared = fmt::compile<int>("test {}");
EXPECT_EQ("test 42", fmt::format(prepared, 42));
......@@ -155,12 +121,14 @@ TEST(CompileTest, FormattedSize) {
struct formattable {};
FMT_BEGIN_NAMESPACE
template <>
struct fmt::formatter<formattable> : formatter<const char*> {
struct formatter<formattable> : formatter<const char*> {
auto format(formattable, format_context& ctx) -> decltype(ctx.out()) {
return formatter<const char*>::format("foo", ctx);
}
};
FMT_END_NAMESPACE
TEST(CompileTest, FormatUserDefinedType) {
auto f = fmt::compile<formattable>("{}");
......
......@@ -690,9 +690,9 @@ struct formatter {
template <typename FormatContext>
auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) {
fmt::internal::handle_dynamic_spec<fmt::internal::width_checker>(
specs_.width, specs_.width_ref, ctx, nullptr);
specs_.width, specs_.width_ref, ctx);
fmt::internal::handle_dynamic_spec<fmt::internal::precision_checker>(
specs_.precision, specs_.precision_ref, ctx, nullptr);
specs_.precision, specs_.precision_ref, ctx);
using range_type = fmt::internal::output_range<typename FormatContext::iterator,
typename FormatContext::char_type>;
return visit_format_arg(arg_formatter<range_type>(ctx, nullptr, &specs_),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment