Add code from p0645
This commit is contained in:
+9
-5
@@ -1042,7 +1042,7 @@ class context_base {
|
||||
|
||||
// Checks if manual indexing is used and returns the argument with
|
||||
// specified index.
|
||||
format_arg get_arg(unsigned arg_id) {
|
||||
format_arg arg(unsigned arg_id) {
|
||||
return this->parse_context().check_arg_id(arg_id) ? this->do_get_arg(arg_id)
|
||||
: format_arg();
|
||||
}
|
||||
@@ -1125,11 +1125,11 @@ class basic_format_context
|
||||
void operator=(const basic_format_context&) = delete;
|
||||
|
||||
typedef internal::context_base<OutputIt, basic_format_context, Char> base;
|
||||
typedef typename base::format_arg format_arg;
|
||||
using base::get_arg;
|
||||
using base::arg;
|
||||
|
||||
public:
|
||||
using typename base::iterator;
|
||||
typedef typename base::format_arg format_arg;
|
||||
|
||||
/**
|
||||
Constructs a ``basic_format_context`` object. References to the arguments are
|
||||
@@ -1143,11 +1143,15 @@ class basic_format_context
|
||||
format_arg next_arg() {
|
||||
return this->do_get_arg(this->parse_context().next_arg_id());
|
||||
}
|
||||
format_arg get_arg(unsigned arg_id) { return this->do_get_arg(arg_id); }
|
||||
format_arg arg(unsigned arg_id) { return this->do_get_arg(arg_id); }
|
||||
|
||||
// Checks if manual indexing is used and returns the argument with the
|
||||
// specified name.
|
||||
format_arg get_arg(basic_string_view<char_type> name);
|
||||
format_arg arg(basic_string_view<char_type> name);
|
||||
|
||||
// DEPRECATED!
|
||||
format_arg get_arg(unsigned arg_id) { return arg(arg_id); }
|
||||
format_arg get_arg(basic_string_view<char_type> name) { return arg(name); }
|
||||
};
|
||||
|
||||
template <typename Char> struct buffer_context {
|
||||
|
||||
+11
-11
@@ -1662,10 +1662,9 @@ template <typename Handler> class specs_checker : public Handler {
|
||||
numeric_specs_checker<Handler> checker_;
|
||||
};
|
||||
|
||||
template <template <typename> class Handler, typename T, typename Context,
|
||||
template <template <typename> class Handler, typename T, typename FormatArg,
|
||||
typename ErrorHandler>
|
||||
FMT_CONSTEXPR void set_dynamic_spec(T& value, basic_format_arg<Context> arg,
|
||||
ErrorHandler eh) {
|
||||
FMT_CONSTEXPR void set_dynamic_spec(T& value, FormatArg arg, ErrorHandler eh) {
|
||||
unsigned long long big_value =
|
||||
visit_format_arg(Handler<ErrorHandler>(eh), arg);
|
||||
if (big_value > to_unsigned((std::numeric_limits<int>::max)()))
|
||||
@@ -1698,14 +1697,15 @@ class specs_handler : public specs_setter<typename Context::char_type> {
|
||||
void on_error(const char* message) { context_.on_error(message); }
|
||||
|
||||
private:
|
||||
FMT_CONSTEXPR basic_format_arg<Context> get_arg(auto_id) {
|
||||
return context_.next_arg();
|
||||
}
|
||||
// This is only needed for compatibility with gcc 4.4.
|
||||
typedef typename Context::format_arg format_arg;
|
||||
|
||||
FMT_CONSTEXPR format_arg get_arg(auto_id) { return context_.next_arg(); }
|
||||
|
||||
template <typename Id>
|
||||
FMT_CONSTEXPR basic_format_arg<Context> get_arg(Id arg_id) {
|
||||
FMT_CONSTEXPR format_arg get_arg(Id arg_id) {
|
||||
context_.parse_context().check_arg_id(arg_id);
|
||||
return context_.get_arg(arg_id);
|
||||
return context_.arg(arg_id);
|
||||
}
|
||||
|
||||
Context& context_;
|
||||
@@ -2174,12 +2174,12 @@ void handle_dynamic_spec(Spec& value, arg_ref<typename Context::char_type> ref,
|
||||
case arg_ref<char_type>::NONE:
|
||||
break;
|
||||
case arg_ref<char_type>::INDEX:
|
||||
internal::set_dynamic_spec<Handler>(value, ctx.get_arg(ref.val.index),
|
||||
internal::set_dynamic_spec<Handler>(value, ctx.arg(ref.val.index),
|
||||
ctx.error_handler());
|
||||
break;
|
||||
case arg_ref<char_type>::NAME: {
|
||||
const auto arg_id = ref.val.name.to_view(ctx.parse_context().begin());
|
||||
internal::set_dynamic_spec<Handler>(value, ctx.get_arg(arg_id),
|
||||
internal::set_dynamic_spec<Handler>(value, ctx.arg(arg_id),
|
||||
ctx.error_handler());
|
||||
} break;
|
||||
}
|
||||
@@ -3050,7 +3050,7 @@ template <typename Char = char> class dynamic_formatter {
|
||||
|
||||
template <typename Range, typename Char>
|
||||
typename basic_format_context<Range, Char>::format_arg
|
||||
basic_format_context<Range, Char>::get_arg(basic_string_view<char_type> name) {
|
||||
basic_format_context<Range, Char>::arg(basic_string_view<char_type> name) {
|
||||
map_.init(this->args());
|
||||
format_arg arg = map_.find(name);
|
||||
if (arg.type() == internal::none_type) this->on_error("argument not found");
|
||||
|
||||
@@ -418,7 +418,7 @@ typename basic_printf_context<OutputIt, Char, AF>::format_arg
|
||||
basic_printf_context<OutputIt, Char, AF>::get_arg(unsigned arg_index) {
|
||||
if (arg_index == std::numeric_limits<unsigned>::max())
|
||||
return this->do_get_arg(this->parse_context().next_arg_id());
|
||||
return base::get_arg(arg_index - 1);
|
||||
return base::arg(arg_index - 1);
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char, typename AF>
|
||||
|
||||
Reference in New Issue
Block a user