diff --git a/fmt/format.h b/fmt/format.h index 54b73963..4432c770 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -1041,6 +1041,8 @@ struct Arg : Value { template struct NamedArg; +template +struct NamedArgWithType; template struct Null {}; @@ -1322,9 +1324,13 @@ class MakeValue : public Arg { // uses char. template MakeValue(const NamedArg &value) { pointer = &value; } + template + MakeValue(const NamedArgWithType &value) { pointer = &value; } template static uint64_t type(const NamedArg &) { return Arg::NAMED_ARG; } + template + static uint64_t type(const NamedArgWithType &) { return Arg::NAMED_ARG; } }; template @@ -1350,6 +1356,12 @@ struct NamedArg : Arg { : Arg(MakeArg< BasicFormatter >(value)), name(argname) {} }; +template +struct NamedArgWithType : NamedArg { + NamedArgWithType(BasicStringRef argname, const T &value) + : NamedArg(argname, value) {} +}; + class RuntimeError : public std::runtime_error { protected: RuntimeError() : std::runtime_error("") {} @@ -3331,13 +3343,13 @@ inline void format_decimal(char *&buffer, T value) { \endrst */ template -inline internal::NamedArg arg(StringRef name, const T &arg) { - return internal::NamedArg(name, arg); +inline internal::NamedArgWithType arg(StringRef name, const T &arg) { + return internal::NamedArgWithType(name, arg); } template -inline internal::NamedArg arg(WStringRef name, const T &arg) { - return internal::NamedArg(name, arg); +inline internal::NamedArgWithType arg(WStringRef name, const T &arg) { + return internal::NamedArgWithType(name, arg); } // The following two functions are deleted intentionally to disable @@ -3782,7 +3794,7 @@ struct UdlArg { const Char *str; template - NamedArg operator=(T &&value) const { + NamedArgWithType operator=(T &&value) const { return {str, std::forward(value)}; } };