Skip to content

Commit

Permalink
Review remarks v3
Browse files Browse the repository at this point in the history
- Moved auto_id back on its place.
- Reverted pointer_from FMT_CONSTEXPR_DECL changes.
- Made NameRefCreator a dynamic_specs_handler's base class.
  • Loading branch information
stryku committed Dec 12, 2018
1 parent dc2a2ae commit c510d82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 0 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,6 @@ enum : unsigned long long { is_unpacked_bit = 1ull << 63 };

template <typename Context>
class arg_map;

struct auto_id {};
} // namespace internal

// A formatting argument. It is a trivially copyable/constructible type to
Expand Down
18 changes: 10 additions & 8 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ template <typename Char>
class null_terminating_iterator;

template <typename Char>
FMT_CONSTEXPR const Char *pointer_from(null_terminating_iterator<Char> it);
FMT_CONSTEXPR_DECL const Char *pointer_from(null_terminating_iterator<Char> it);

// An iterator that produces a null terminator on *end. This simplifies parsing
// and allows comparing the performance of processing a null-terminated string
Expand Down Expand Up @@ -696,7 +696,7 @@ class null_terminating_iterator {
// This should be a friend specialization pointer_from<Char> but the latter
// doesn't compile by gcc 5.1 due to a compiler bug.
template <typename CharT>
friend FMT_CONSTEXPR const CharT *pointer_from(
friend FMT_CONSTEXPR_DECL const CharT *pointer_from(
null_terminating_iterator<CharT> it);

private:
Expand Down Expand Up @@ -1804,6 +1804,8 @@ FMT_CONSTEXPR void set_dynamic_spec(
value = static_cast<T>(big_value);
}

struct auto_id {};

// The standard format specifier handler with checking.
template <typename Context>
class specs_handler: public specs_setter<typename Context::char_type> {
Expand Down Expand Up @@ -1942,7 +1944,8 @@ template <typename Specs, typename ParseContext,
typename NameRefCreator = string_value_name_arg_ref_creator<
typename ParseContext::char_type>>
class dynamic_specs_handler
: public specs_setter<typename ParseContext::char_type> {
: private NameRefCreator,
public specs_setter<typename ParseContext::char_type> {
protected:
typedef typename NameRefCreator::arg_ref_type arg_ref_type;

Expand All @@ -1952,10 +1955,10 @@ class dynamic_specs_handler
FMT_CONSTEXPR dynamic_specs_handler(
Specs &specs, ParseContext &ctx,
NameRefCreator name_ref_creator = NameRefCreator())
: specs_setter<char_type>(specs),
: NameRefCreator(name_ref_creator),
specs_setter<char_type>(specs),
specs_(specs),
context_(ctx),
name_ref_creator_(name_ref_creator) {}
context_(ctx) {}

template <typename Id>
FMT_CONSTEXPR void on_dynamic_width(Id arg_id) {
Expand Down Expand Up @@ -1992,7 +1995,7 @@ class dynamic_specs_handler
FMT_CONSTEXPR arg_ref_type
make_name_arg_ref(basic_string_view<char_type> arg_id) {
context_.check_arg_id(arg_id);
return name_ref_creator_.make_name_arg_ref(arg_id);
return NameRefCreator::make_name_arg_ref(arg_id);
}

template <typename Id>
Expand All @@ -2003,7 +2006,6 @@ class dynamic_specs_handler
private:
Specs &specs_;
ParseContext &context_;
NameRefCreator name_ref_creator_;
};

template <typename Char>
Expand Down

0 comments on commit c510d82

Please sign in to comment.