diff --git a/include/fmt/base.h b/include/fmt/base.h index 8c0411bf..010812c7 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -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_; } diff --git a/test/base-test.cc b/test/base-test.cc index 52089fea..f8af275d 100644 --- a/test/base-test.cc +++ b/test/base-test.cc @@ -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()); + } + }; +}