Commit a38b99a1 authored by Victor Zverovich's avatar Victor Zverovich

Fix a regression in named argument handling introduced by prepare

parent aa31028b
...@@ -1806,11 +1806,9 @@ struct string_view_metadata { ...@@ -1806,11 +1806,9 @@ struct string_view_metadata {
: offset_(view.data() - primary_string.data()), size_(view.size()) {} : offset_(view.data() - primary_string.data()), size_(view.size()) {}
FMT_CONSTEXPR string_view_metadata(std::size_t offset, std::size_t size) FMT_CONSTEXPR string_view_metadata(std::size_t offset, std::size_t size)
: offset_(offset), size_(size) {} : offset_(offset), size_(size) {}
template <typename S, typename Char = enable_if_t< template <typename Char>
internal::is_string<S>::value, char_t<S>>> FMT_CONSTEXPR basic_string_view<Char> to_view(const Char* str) const {
FMT_CONSTEXPR basic_string_view<Char> to_view(S&& str) const { return {str + offset_, size_};
const auto view = to_string_view(str);
return basic_string_view<Char>(view.data() + offset_, size_);
} }
std::size_t offset_; std::size_t offset_;
......
...@@ -262,7 +262,7 @@ class prepared_format { ...@@ -262,7 +262,7 @@ class prepared_format {
switch (part.which) { switch (part.which) {
case format_part_t::which_value::text: { case format_part_t::which_value::text: {
const auto text = value.text.to_view(format_view); const auto text = value.text.to_view(format_view.data());
auto output = ctx.out(); auto output = ctx.out();
auto&& it = internal::reserve(output, text.size()); auto&& it = internal::reserve(output, text.size());
it = std::copy_n(text.begin(), text.size(), it); it = std::copy_n(text.begin(), text.size(), it);
...@@ -276,16 +276,17 @@ class prepared_format { ...@@ -276,16 +276,17 @@ class prepared_format {
case format_part_t::which_value::named_argument_id: { case format_part_t::which_value::named_argument_id: {
advance_parse_context_to_specification(parse_ctx, part); advance_parse_context_to_specification(parse_ctx, part);
const auto named_arg_id = value.named_arg_id.to_view(format_view); const auto named_arg_id =
value.named_arg_id.to_view(format_view.data());
format_arg<Range>(parse_ctx, ctx, named_arg_id); format_arg<Range>(parse_ctx, ctx, named_arg_id);
} break; } break;
case format_part_t::which_value::specification: { case format_part_t::which_value::specification: {
const auto& arg_id_value = value.spec.arg_id.val; const auto& arg_id_value = value.spec.arg_id.val;
const auto arg = const auto arg = value.spec.arg_id.which ==
value.spec.arg_id.which == format_part_t::argument_id::which_arg_id::index
format_part_t::argument_id::which_arg_id::index ? ctx.arg(arg_id_value.index)
? ctx.arg(arg_id_value.index) : ctx.arg(arg_id_value.named_index.to_view(
: ctx.arg(arg_id_value.named_index.to_view(format_)); to_string_view(format_).data()));
auto specs = value.spec.parsed_specs; auto specs = value.spec.parsed_specs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment