Skip to content

Commit

Permalink
Use MakeArg constructor instead of manually constructing Arg
Browse files Browse the repository at this point in the history
  • Loading branch information
dean0x7d committed Dec 6, 2015
1 parent 6ea14f0 commit 983b883
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1218,14 +1218,9 @@ template <typename Char>
struct NamedArg : Arg {
BasicStringRef<Char> name;

typedef internal::MakeValue< BasicFormatter<Char> > MakeValue;

template <typename T>
NamedArg(BasicStringRef<Char> argname, const T &x)
: name(argname) {
value = MakeValue(x);
type = static_cast<Arg::Type>(MakeValue::type(x));
}
: Arg(internal::MakeArg< BasicFormatter<Char> >(x)), name(argname) {}
};

#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call
Expand Down Expand Up @@ -2900,11 +2895,8 @@ void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value) {
output << value;

BasicStringRef<Char> str(&buffer[0], format_buf.size());
typedef internal::MakeValue< BasicFormatter<Char> > MakeValue;
internal::Arg arg;
arg.value = MakeValue(str);
arg.type = static_cast<internal::Arg::Type>(MakeValue::type(str));
format_str = f.format(format_str, arg);
typedef internal::MakeArg< BasicFormatter<Char> > MakeArg;
format_str = f.format(format_str, MakeArg(str));
}

// Reports a system error without throwing an exception.
Expand Down

0 comments on commit 983b883

Please sign in to comment.