From 8bbb0b48b418b9f0e13536fca776740875c93476 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 15 Aug 2018 06:34:34 -0700 Subject: [PATCH] Update README.rst --- README.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.rst b/README.rst index 6c3ea7c2..771f0b63 100644 --- a/README.rst +++ b/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 + 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 -------