File: overload_test.cc

package info (click to toggle)
benchmark 1.9.5-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,820 kB
  • sloc: cpp: 14,339; python: 2,399; ansic: 38; sh: 28; makefile: 14
file content (35 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "benchmark/benchmark.h"

namespace {
// Simulate an overloaded function name.
// This version does nothing and is just here to create ambiguity for
// MyOverloadedBenchmark.
BENCHMARK_UNUSED void MyOverloadedBenchmark() {}

// This is the actual benchmark function we want to register.
// It has the signature void(benchmark::State&) required by the library.
void MyOverloadedBenchmark(benchmark::State& state) {
  for (auto _ : state) {
  }
}

// This macro invocation should compile correctly if benchmark.h
// contains the fix (using static_cast), but would fail to compile
// if the benchmark name were ambiguous (e.g., when using + or no cast
// with an overloaded function).
BENCHMARK(MyOverloadedBenchmark);

// Also test BENCHMARK_TEMPLATE with an overloaded name.
template <int N>
void MyTemplatedOverloadedBenchmark() {}

template <int N>
void MyTemplatedOverloadedBenchmark(benchmark::State& state) {
  for (auto _ : state) {
  }
}

BENCHMARK_TEMPLATE(MyTemplatedOverloadedBenchmark, 1);
}  // end namespace

BENCHMARK_MAIN();