diff --git a/include/fmt/core.h b/include/fmt/core.h index 88486cfa..be0b6a88 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -655,7 +655,7 @@ template class basic_format_parse_context { public: using char_type = Char; - using iterator = typename basic_string_view::iterator; + using iterator = const Char*; explicit constexpr basic_format_parse_context( basic_string_view format_str, int next_arg_id = 0) @@ -1785,6 +1785,7 @@ template class basic_format_context { public: using iterator = OutputIt; using format_arg = basic_format_arg; + using format_args = basic_format_args; using parse_context_type = basic_format_parse_context; template using formatter_type = formatter; @@ -1795,12 +1796,11 @@ template class basic_format_context { basic_format_context(const basic_format_context&) = delete; void operator=(const basic_format_context&) = delete; /** - Constructs a ``basic_format_context`` object. References to the arguments are - stored in the object so make sure they have appropriate lifetimes. + Constructs a ``basic_format_context`` object. References to the arguments + are stored in the object so make sure they have appropriate lifetimes. */ - constexpr basic_format_context( - OutputIt out, basic_format_args ctx_args, - detail::locale_ref loc = detail::locale_ref()) + constexpr basic_format_context(OutputIt out, format_args ctx_args, + detail::locale_ref loc = {}) : out_(out), args_(ctx_args), loc_(loc) {} constexpr auto arg(int id) const -> format_arg { return args_.get(id); } @@ -1810,9 +1810,7 @@ template class basic_format_context { FMT_CONSTEXPR auto arg_id(basic_string_view name) -> int { return args_.get_id(name); } - auto args() const -> const basic_format_args& { - return args_; - } + auto args() const -> const format_args& { return args_; } FMT_CONSTEXPR auto error_handler() -> detail::error_handler { return {}; } void on_error(const char* message) { error_handler().on_error(message); } @@ -2833,7 +2831,7 @@ template class format_string_checker { FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char*) -> const Char* { - context_.advance_to(context_.begin() + (begin - &*context_.begin())); + context_.advance_to(begin); // id >= 0 check is a workaround for gcc 10 bug (#2065). return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin; } @@ -2858,9 +2856,8 @@ void check_format_string(S format_str) { using char_t = typename S::char_type; FMT_CONSTEXPR auto s = basic_string_view(format_str); using checker = format_string_checker...>; - FMT_CONSTEXPR bool invalid_format = - (parse_format_string(s, checker(s)), true); - ignore_unused(invalid_format); + FMT_CONSTEXPR bool error = (parse_format_string(s, checker(s)), true); + ignore_unused(error); } // Don't use type_identity for args to simplify symbols. @@ -2885,7 +2882,7 @@ struct formatter - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(ParseContext& ctx) -> const Char* { auto begin = ctx.begin(), end = ctx.end(); if (begin == end) return begin; auto type = detail::type_constant::value; @@ -2893,6 +2890,8 @@ struct formatter class basic_format_string { basic_format_string(runtime_format_string fmt) : str_(fmt.str) {} FMT_INLINE operator basic_string_view() const { return str_; } - FMT_INLINE basic_string_view get() const { return str_; } + FMT_INLINE auto get() const -> basic_string_view { return str_; } }; #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409