Add args() accessor back to fmt::format_context (#4310)

Add args() accessor back to fmt::format_context
Add test that would fail to compile if you can't create a fmt::format_context from another fmt::format_context
This commit is contained in:
Aaron Bishop 2025-01-17 13:28:34 -05:00 committed by GitHub
parent 01914f0389
commit 937b7c5c10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -2656,6 +2656,7 @@ class context {
FMT_CONSTEXPR auto arg_id(string_view name) const -> int {
return args_.get_id(name);
}
auto args() const -> const format_args& { return args_; }
// Returns an iterator to the beginning of the output range.
FMT_CONSTEXPR auto out() const -> iterator { return out_; }

View File

@ -875,3 +875,12 @@ TEST(base_test, no_repeated_format_string_conversions) {
fmt::format_to(buf, nondeterministic_format_string());
#endif
}
TEST(base_test, format_context_accessors) {
class copier {
static fmt::format_context copy(fmt::appender app,
const fmt::format_context& ctx) {
return fmt::format_context(std::move(app), ctx.args(), ctx.locale());
}
};
}