From 00e2211052872f485380465b0c4790fdb2624700 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Mon, 17 Jan 2022 13:54:56 +0000 Subject: [PATCH] Expand documentation for unpacking arbitrary arguments. (#1324) Fixes #1123 --- docs/user_guide.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/user_guide.md b/docs/user_guide.md index 919e0f0c..14a4a212 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -436,13 +436,22 @@ The `test_case_name` is appended to the name of the benchmark and should describe the values passed. ```c++ -template -void BM_takes_args(benchmark::State& state, ExtraArgs&&... extra_args) { - [...] +template +void BM_takes_args(benchmark::State& state, Args&&... args) { + auto args_tuple = std::make_tuple(std::move(args)...); + for (auto _ : state) { + std::cout << std::get<0>(args_tuple) << ": " << std::get<1>(args_tuple) + << '\n'; + [...] + } } // Registers a benchmark named "BM_takes_args/int_string_test" that passes -// the specified values to `extra_args`. +// the specified values to `args`. BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc")); + +// Registers the same benchmark "BM_takes_args/int_test" that passes +// the specified values to `args`. +BENCHMARK_CAPTURE(BM_takes_args, int_test, 42, 43); ``` Note that elements of `...args` may refer to global variables. Users should