Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow templated functions in BENCHMARK macro #44

Open
DarkoVeberic opened this issue Mar 26, 2021 · 0 comments
Open

Allow templated functions in BENCHMARK macro #44

DarkoVeberic opened this issue Mar 26, 2021 · 0 comments

Comments

@DarkoVeberic
Copy link

Because of the ## magic that you use in the BENCKMARK macro, for the example below I had to introduce two temporary variables TestList and TestDeque to pass them into the macro:

#include <list>
#include <deque>

template<class Container>
static
void
Test(benchmark::State& state)
{
  Container x;
  for (auto _ : state) {
    x.push_back(i);
    x.push_front(i);
    x.pop_back();
    x.pop_front();
  }
}

const auto TestList = Test<std::list<int>>;
const auto TestDeque = Test<std::deque<int>>;

BENCHMARK(TestList);
BENCHMARK(TestDeque);

It would be nice if I could simply write:

BENCHMARK(Test<std::list<int>>);
BENCHMARK(Test<std::deque<int>>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant