diff --git a/include/fmt/base.h b/include/fmt/base.h index 7b678d7d..2700e631 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -2627,18 +2627,20 @@ class context : private detail::locale_ref { void operator=(const context&) = delete; FMT_CONSTEXPR auto arg(int id) const -> format_arg { return args_.get(id); } - inline auto arg(string_view name) -> format_arg { return args_.get(name); } - FMT_CONSTEXPR auto arg_id(string_view name) -> int { + inline auto arg(string_view name) const -> format_arg { + return args_.get(name); + } + FMT_CONSTEXPR auto arg_id(string_view name) const -> int { return args_.get_id(name); } // Returns an iterator to the beginning of the output range. - FMT_CONSTEXPR auto out() -> iterator { return out_; } + FMT_CONSTEXPR auto out() const -> iterator { return out_; } // Advances the begin iterator to `it`. FMT_CONSTEXPR void advance_to(iterator) {} - FMT_CONSTEXPR auto locale() -> detail::locale_ref { return *this; } + FMT_CONSTEXPR auto locale() const -> detail::locale_ref { return *this; } }; template struct runtime_format_string { diff --git a/include/fmt/format.h b/include/fmt/format.h index a8091cbf..6c729a60 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3708,20 +3708,21 @@ template class generic_context { constexpr auto arg(int id) const -> basic_format_arg { return args_.get(id); } - auto arg(basic_string_view name) -> basic_format_arg { + auto arg(basic_string_view name) const + -> basic_format_arg { return args_.get(name); } - FMT_CONSTEXPR auto arg_id(basic_string_view name) -> int { + constexpr auto arg_id(basic_string_view name) const -> int { return args_.get_id(name); } - FMT_CONSTEXPR auto out() -> iterator { return out_; } + constexpr auto out() const -> iterator { return out_; } void advance_to(iterator it) { if (!detail::is_back_insert_iterator()) out_ = it; } - FMT_CONSTEXPR auto locale() -> detail::locale_ref { return loc_; } + constexpr auto locale() const -> detail::locale_ref { return loc_; } }; class loc_value {