Fix const[expr] in context API

This commit is contained in:
Victor Zverovich 2024-11-03 07:25:52 -08:00
parent 6580d7b808
commit cf50e4d6a4
2 changed files with 11 additions and 8 deletions

View File

@ -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 <typename Char = char> struct runtime_format_string {

View File

@ -3708,20 +3708,21 @@ template <typename OutputIt, typename Char> class generic_context {
constexpr auto arg(int id) const -> basic_format_arg<generic_context> {
return args_.get(id);
}
auto arg(basic_string_view<Char> name) -> basic_format_arg<generic_context> {
auto arg(basic_string_view<Char> name) const
-> basic_format_arg<generic_context> {
return args_.get(name);
}
FMT_CONSTEXPR auto arg_id(basic_string_view<Char> name) -> int {
constexpr auto arg_id(basic_string_view<Char> 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<iterator>()) out_ = it;
}
FMT_CONSTEXPR auto locale() -> detail::locale_ref { return loc_; }
constexpr auto locale() const -> detail::locale_ref { return loc_; }
};
class loc_value {