Improve handling of named arguments

This commit is contained in:
Victor Zverovich
2020-04-14 11:56:55 -07:00
parent a9d62d3f35
commit 8a4630686e
8 changed files with 112 additions and 121 deletions
+19
View File
@@ -114,6 +114,25 @@ char* sprintf_format(Double value, internal::buffer<char>& buf,
}
return decimal_point_pos;
}
// This is deprecated and is kept only to preserve ABI compatibility.
template <typename Context>
void arg_map<Context>::init(const basic_format_args<Context>& args) {
if (map_) return;
map_ = new entry[internal::to_unsigned(args.max_size())];
if (args.is_packed()) {
for (int i = 0;; ++i) {
internal::type arg_type = args.type(i);
if (arg_type == internal::type::none_type) return;
if (arg_type == internal::type::named_arg_type)
push_back(args.values_[i]);
}
}
for (int i = 0, n = args.max_size(); i < n; ++i) {
auto type = args.args_[i].type_;
if (type == internal::type::named_arg_type) push_back(args.args_[i].value_);
}
}
} // namespace internal
template FMT_API char* internal::sprintf_format(double, internal::buffer<char>&,