template<typename Context>
class dynamic_format_arg_store< Context >
A dynamic version of fmt::format_arg_store
. It's equipped with a storage to potentially temporary objects which lifetimes could be shorter than the format arguments object.
It can be implicitly converted into ~fmtbasic_format_args
for passing into type-erased formatting functions such as ~fmtvformat
.
Definition at line 618 of file core.h.
template<typename Context>
template<typename T >
Adds an argument into the dynamic store for later passing to a formatting function.
Note that custom types and string types (but not string views) are copied into the store dynamically allocating memory if necessary.
Example**::
fmt::dynamic_format_arg_store<fmt::format_context> store; store.push_back(42); store.push_back("abc"); store.push_back(1.5f); std::string result = fmt::vformat("{} and {} and {}", store);
Definition at line 1759 of file core.h.
template<typename Context>
template<typename T >
Adds a reference to the argument into the dynamic store for later passing to a formatting function. Supports named arguments wrapped in std::reference_wrapper
via std::ref()
/std::cref()
.
Example**::
fmt::dynamic_format_arg_store<fmt::format_context> store; char str[] = "1234567890"; store.push_back(std::cref(str)); int a1_val{42}; auto a1 = fmt::arg("a1_", a1_val); store.push_back(std::cref(a1));
Changing str affects the output but only for string and custom types. str[0] = 'X';
std::string result = fmt::vformat("{} and {a1_}"); assert(result == "X234567890 and 42");
Definition at line 1788 of file core.h.