diff --git a/format.h b/format.h index 157e5170..89ec1177 100644 --- a/format.h +++ b/format.h @@ -1200,6 +1200,16 @@ class MakeValue : public Value { static uint64_t type(const NamedArg &) { return Arg::NAMED_ARG; } }; +template +class MakeArg : public Arg { +public: + template + MakeArg(const T &x) { + value = MakeValue(x); + type = static_cast(MakeValue::type(x)); + } +}; + template struct NamedArg : Arg { BasicStringRef name; @@ -1908,36 +1918,20 @@ inline uint64_t make_type(const Arg &first, const Args & ... tail) { return make_type(first) | (make_type(tail...) << 4); } -inline void do_set_types(Arg *) {} - -template -inline void do_set_types(Arg *args, const T &arg, const Args & ... tail) { - args->type = static_cast( - MakeValue< BasicFormatter >::type(arg)); - do_set_types(args + 1, tail...); +template +inline void store_args(Arg *args) { + *args = Arg{0, Arg::NONE}; } -template -inline void set_types(Arg *array, const Args & ... args) { - if (check(sizeof...(Args) > ArgList::MAX_PACKED_ARGS)) - do_set_types(array, args...); - array[sizeof...(Args)].type = Arg::NONE; -} - -template -inline void set_types(Value *, const Args & ...) { - // Do nothing as types are passed separately from values. -} - -template -inline void store_args(Value *) {} - template inline void store_args(Arg *args, const T &arg, const Args & ... tail) { - args->value = MakeValue(arg); + *args = MakeArg(arg); store_args(args + 1, tail...); } +template +inline void store_args(Value *) {} + template inline void store_args(Value *args, const T &arg, const Args & ... tail) { *args = MakeValue(arg); @@ -1947,8 +1941,6 @@ inline void store_args(Value *args, const T &arg, const Args & ... tail) { template ArgList make_arg_list(typename ArgArray::Type array, const Args & ... args) { - if (check(sizeof...(Args) >= ArgList::MAX_PACKED_ARGS)) - set_types(array, args...); store_args(array, args...); return ArgList(make_type(args...), array); }