diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-03-18 14:42:35 -0400 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-03-18 14:42:35 -0400 |
commit | b7d03ac4f533eaa11026fcf17ed11fc3dbc287a3 (patch) | |
tree | 5f892fa704a421c45a938b192276fc6893e6eeea /include/benchmark | |
parent | 92fc9b99b2b921988e2be847f5d5b967127c58d2 (diff) | |
download | google-benchmark-b7d03ac4f533eaa11026fcf17ed11fc3dbc287a3.tar.gz |
Add BENCHMARK_TEMPLATE1 macro
Diffstat (limited to 'include/benchmark')
-rw-r--r-- | include/benchmark/benchmark_api.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/benchmark/benchmark_api.h b/include/benchmark/benchmark_api.h index 41b8b4f..ab1f84a 100644 --- a/include/benchmark/benchmark_api.h +++ b/include/benchmark/benchmark_api.h @@ -445,7 +445,7 @@ class Benchmark { // BENCHMARK_TEMPLATE(BM_Foo, 1); // // will register BM_Foo<1> as a benchmark. -#define BENCHMARK_TEMPLATE(n, a) \ +# define BENCHMARK_TEMPLATE1(n, a) \ static ::benchmark::internal::Benchmark* BENCHMARK_CONCAT( \ __benchmark_, n, __LINE__) BENCHMARK_UNUSED = \ (new ::benchmark::internal::Benchmark(#n "<" #a ">", n<a>)) @@ -455,6 +455,16 @@ class Benchmark { __benchmark_, n, __LINE__) BENCHMARK_UNUSED = \ (new ::benchmark::internal::Benchmark(#n "<" #a "," #b ">", n<a, b>)) +#if __cplusplus >= 201103L +#define BENCHMARK_TEMPLATE(n, ...) \ + static ::benchmark::internal::Benchmark* BENCHMARK_CONCAT( \ + _benchmark_, n, __LINE__) BENCHMARK_UNUSED = \ + (new ::benchmark::internal::Benchmark( \ + #n "<" #__VA_ARGS__ ">", n< __VA_ARGS__ > )) +#else +#define BENCHMARK_TEMPLATE(n, a) BENCHMARK_TEMPLATE1(n, a) +#endif + // Helper macro to create a main routine in a test that runs the benchmarks #define BENCHMARK_MAIN() \ int main(int argc, const char** argv) { \ |