Docs for fmt::arg() seem to indicate that the returned object my depend on temporaries created in the function call expression, and that it would be unsafe to use the returned object after the full expression expires.
|
Returns a named argument to be used in a formatting function. It should only |
|
be used in a call to a formatting function. |
That's no longer true as other examples like
|
auto a1 = fmt::arg("a1_", a1_val); |
|
store.push_back(std::cref(a1)); |
show the result being retained in
auto variables and passed to
fmt::dynamic_format_arg_store via
push_back.
I want to use dynamic_format_arg_store but it looks like I'm breaking the fmt::arg contract to do it.
I know it's safe, but the docs don't quite match the reality.
Should the "It should only be used in a call to a formatting function" be removed or updated?
Docs for
fmt::arg()seem to indicate that the returned object my depend on temporaries created in the function call expression, and that it would be unsafe to use the returned object after the full expression expires.fmt/include/fmt/core.h
Lines 1622 to 1623 in b8ff3c1
That's no longer true as other examples like
fmt/include/fmt/args.h
Lines 180 to 181 in b8ff3c1
autovariables and passed tofmt::dynamic_format_arg_storeviapush_back.I want to use
dynamic_format_arg_storebut it looks like I'm breaking thefmt::argcontract to do it.I know it's safe, but the docs don't quite match the reality.
Should the "It should only be used in a call to a formatting function" be removed or updated?