mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-23 10:50:05 +00:00
Remove unnecessary template arg from basic_format_args
This commit is contained in:
parent
f69786a715
commit
939aff2936
29
fmt/format.h
29
fmt/format.h
@ -1327,7 +1327,7 @@ basic_format_arg<Context> make_arg(const T &value);
|
||||
|
||||
struct monostate {};
|
||||
|
||||
template <typename Context, typename Char>
|
||||
template <typename Context>
|
||||
class basic_format_args;
|
||||
|
||||
// A formatting argument. It is a trivially copyable/constructible type to
|
||||
@ -1345,7 +1345,7 @@ class basic_format_arg {
|
||||
friend typename std::result_of<Visitor(int)>::type
|
||||
visit(Visitor &&vis, basic_format_arg<Ctx> arg);
|
||||
|
||||
friend class basic_format_args<Context, typename Context::char_type>;
|
||||
friend class basic_format_args<Context>;
|
||||
friend class internal::ArgMap<Context>;
|
||||
|
||||
public:
|
||||
@ -1553,7 +1553,7 @@ inline format_arg_store<format_context, Args...>
|
||||
}
|
||||
|
||||
/** Formatting arguments. */
|
||||
template <typename Context, typename Char>
|
||||
template <typename Context>
|
||||
class basic_format_args {
|
||||
public:
|
||||
typedef unsigned size_type;
|
||||
@ -1626,8 +1626,8 @@ class basic_format_args {
|
||||
}
|
||||
};
|
||||
|
||||
typedef basic_format_args<basic_format_context<char>, char> format_args;
|
||||
typedef basic_format_args<basic_format_context<wchar_t>, wchar_t> wformat_args;
|
||||
typedef basic_format_args<format_context> format_args;
|
||||
typedef basic_format_args<wformat_context> wformat_args;
|
||||
|
||||
enum Alignment {
|
||||
ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_NUMERIC
|
||||
@ -1863,7 +1863,7 @@ class ArgMap {
|
||||
MapType map_;
|
||||
|
||||
public:
|
||||
void init(const basic_format_args<Context, Char> &args);
|
||||
void init(const basic_format_args<Context> &args);
|
||||
|
||||
const basic_format_arg<Context>
|
||||
*find(const fmt::BasicStringRef<Char> &name) const {
|
||||
@ -1878,7 +1878,7 @@ class ArgMap {
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
void ArgMap<Context>::init(const basic_format_args<Context, Char> &args) {
|
||||
void ArgMap<Context>::init(const basic_format_args<Context> &args) {
|
||||
if (!map_.empty())
|
||||
return;
|
||||
typedef internal::NamedArg<Context> NamedArg;
|
||||
@ -2050,18 +2050,17 @@ template <typename Char, typename Context>
|
||||
class format_context_base {
|
||||
private:
|
||||
const Char *ptr_;
|
||||
basic_format_args<Context, Char> args_;
|
||||
basic_format_args<Context> args_;
|
||||
int next_arg_index_;
|
||||
|
||||
protected:
|
||||
typedef basic_format_arg<Context> format_arg;
|
||||
|
||||
format_context_base(const Char *format_str,
|
||||
basic_format_args<Context, Char> args)
|
||||
format_context_base(const Char *format_str, basic_format_args<Context> args)
|
||||
: ptr_(format_str), args_(args), next_arg_index_(0) {}
|
||||
~format_context_base() {}
|
||||
|
||||
basic_format_args<Context, Char> args() const { return args_; }
|
||||
basic_format_args<Context> args() const { return args_; }
|
||||
|
||||
// Returns the argument with specified index.
|
||||
format_arg do_get_arg(unsigned arg_index, const char *&error) {
|
||||
@ -2157,7 +2156,7 @@ class basic_format_context :
|
||||
\endrst
|
||||
*/
|
||||
basic_format_context(const Char *format_str,
|
||||
basic_format_args<basic_format_context, Char> args)
|
||||
basic_format_args<basic_format_context> args)
|
||||
: Base(format_str, args) {}
|
||||
|
||||
// Parses argument id and returns corresponding argument.
|
||||
@ -2394,7 +2393,7 @@ class BasicWriter {
|
||||
}
|
||||
|
||||
void vwrite(BasicCStringRef<Char> format,
|
||||
basic_format_args<basic_format_context<Char>, Char> args);
|
||||
basic_format_args<basic_format_context<Char>> args);
|
||||
/**
|
||||
\rst
|
||||
Writes formatted data.
|
||||
@ -3578,7 +3577,7 @@ void do_format_arg(BasicWriter<Char> &writer, basic_format_arg<Context> arg,
|
||||
/** Formats arguments and writes the output to the writer. */
|
||||
template <typename ArgFormatter, typename Char, typename Context>
|
||||
void vformat(BasicWriter<Char> &writer, BasicCStringRef<Char> format_str,
|
||||
basic_format_args<Context, Char> args) {
|
||||
basic_format_args<Context> args) {
|
||||
basic_format_context<Char> ctx(format_str.c_str(), args);
|
||||
const Char *&s = ctx.ptr();
|
||||
const Char *start = s;
|
||||
@ -3604,7 +3603,7 @@ void vformat(BasicWriter<Char> &writer, BasicCStringRef<Char> format_str,
|
||||
template <typename Char>
|
||||
inline void BasicWriter<Char>::vwrite(
|
||||
BasicCStringRef<Char> format,
|
||||
basic_format_args<basic_format_context<Char>, Char> args) {
|
||||
basic_format_args<basic_format_context<Char>> args) {
|
||||
vformat<ArgFormatter<Char>>(*this, format, args);
|
||||
}
|
||||
} // namespace fmt
|
||||
|
11
fmt/printf.h
11
fmt/printf.h
@ -282,7 +282,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
|
||||
/** Formats an argument of a custom (user-defined) type. */
|
||||
void operator()(internal::CustomValue<Char> c) {
|
||||
const Char format_str[] = {'}', '\0'};
|
||||
auto args = basic_format_args<basic_format_context<Char>, Char>();
|
||||
auto args = basic_format_args<basic_format_context<Char>>();
|
||||
basic_format_context<Char> ctx(format_str, args);
|
||||
c.format(this->writer(), c.value, &ctx);
|
||||
}
|
||||
@ -322,7 +322,7 @@ class printf_context :
|
||||
\endrst
|
||||
*/
|
||||
explicit printf_context(BasicCStringRef<Char> format_str,
|
||||
basic_format_args<printf_context, Char> args)
|
||||
basic_format_args<printf_context> args)
|
||||
: Base(format_str.c_str(), args) {}
|
||||
|
||||
/** Formats stored arguments and writes the output to the writer. */
|
||||
@ -510,11 +510,11 @@ void format_value(BasicWriter<Char> &w, const T &value,
|
||||
|
||||
template <typename Char>
|
||||
void printf(BasicWriter<Char> &w, BasicCStringRef<Char> format,
|
||||
basic_format_args<printf_context<Char>, Char> args) {
|
||||
basic_format_args<printf_context<Char>> args) {
|
||||
printf_context<Char>(format, args).format(w);
|
||||
}
|
||||
|
||||
typedef basic_format_args<printf_context<char>, char> printf_args;
|
||||
typedef basic_format_args<printf_context<char>> printf_args;
|
||||
|
||||
inline std::string vsprintf(CStringRef format, printf_args args) {
|
||||
MemoryWriter w;
|
||||
@ -537,8 +537,7 @@ inline std::string sprintf(CStringRef format_str, const Args & ... args) {
|
||||
}
|
||||
|
||||
inline std::wstring vsprintf(
|
||||
WCStringRef format,
|
||||
basic_format_args<printf_context<wchar_t>, wchar_t> args) {
|
||||
WCStringRef format, basic_format_args<printf_context<wchar_t>> args) {
|
||||
WMemoryWriter w;
|
||||
printf(w, format, args);
|
||||
return w.str();
|
||||
|
@ -63,7 +63,7 @@ typedef fmt::printf_context<char, CustomPrintfArgFormatter>
|
||||
|
||||
std::string custom_vsprintf(
|
||||
const char* format_str,
|
||||
fmt::basic_format_args<CustomPrintfFormatter, char> args) {
|
||||
fmt::basic_format_args<CustomPrintfFormatter> args) {
|
||||
fmt::MemoryWriter writer;
|
||||
CustomPrintfFormatter formatter(format_str, args);
|
||||
formatter.format(writer);
|
||||
|
Loading…
Reference in New Issue
Block a user