From 455a7c0787617d748fb2307e3783f39942b463f6 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 30 Dec 2019 08:51:47 -1000 Subject: [PATCH] Clarify lifetime of basic_format_args --- include/fmt/core.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 91b3e128..56d1ed71 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1256,7 +1256,16 @@ inline format_arg_store make_format_args( return {args...}; } -/** Formatting arguments. */ +/** + \rst + A view of a collection of formatting arguments. To avoid lifetime issues it + should only be used as a parameter type in type-erased functions such as + ``vformat``:: + + void vlog(fmt::string_view format_str, fmt::format_args args); // OK + fmt::format_args args = fmt::make_format_args(42); // Error: dangling reference + \endrst + */ template class basic_format_args { public: using size_type = int;