change setup and teardown callback type#1934
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
I do believe we could theoretically do this now that C++03 support is gone. |
src/benchmark_register.cc
Outdated
| } | ||
|
|
||
| Benchmark* Benchmark::Setup(void (*setup)(const benchmark::State&)) { | ||
| Benchmark* Benchmark::Setup(callback_function setup) { |
There was a problem hiding this comment.
(I don't know)
I don't remember what the best practice is, should it be taken by && and perhaps moved?
There was a problem hiding this comment.
It looks like you're right. It seems that && is a more appropriate way
I could try to work on this in a separate PR |
|
Where did the tests go? |
1. move the definition of callback_function to the benchmark namespace. in order for the user to use this 2. add overloads for Stup/Teardown
The tests are back |
std::function is already nullptr by default. thus, there is no need to initialize its by by nullptr manually.
|
|
||
| void function(const benchmark::State& /*unused*/) {} | ||
|
|
||
| int main(int argc, char** argv) { |
There was a problem hiding this comment.
this test doesn't appear to be, well, testing anything. can you please take a look at how the other tests are structured and see about making this more useful?
|
if you can merge in the changes and mark this PR as ready to review i think we can get it landed. |
LebedevRI
left a comment
There was a problem hiding this comment.
Seems reasonable-ish.
|
@EfesX thank you! |
Custom Benchmark::Setup and Benchmark::Teardown take std::function. So it is possible to pass any functor there
Fixes #1872