mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-26 20:20:04 +00:00
Update README.rst
This commit is contained in:
parent
5c0101ab2d
commit
8bbb0b48b4
23
README.rst
23
README.rst
@ -429,6 +429,29 @@ or the bloat test::
|
||||
|
||||
$ make bloat-test
|
||||
|
||||
FAQ
|
||||
---
|
||||
|
||||
Q: how can I capture formatting arguments and format them later?
|
||||
|
||||
A: use ``std::tuple``:
|
||||
|
||||
.. code:: c++
|
||||
|
||||
template <typename... Args>
|
||||
auto capture(const Args&... args) {
|
||||
return std::make_tuple(args...);
|
||||
}
|
||||
|
||||
auto print_message = [](const auto&... args) {
|
||||
fmt::print(args...);
|
||||
};
|
||||
|
||||
// Capture and store arguments:
|
||||
auto args = capture("{} {}", 42, "foo");
|
||||
// Do formatting:
|
||||
std::apply(print_message, args);
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user