-
Notifications
You must be signed in to change notification settings - Fork 1.7k
change setup and teardown callback type #1934
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
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
@@ -337,13 +337,13 @@ Benchmark* Benchmark::Apply(void (*custom_arguments)(Benchmark* benchmark)) { | |||
return this; | |||
} | |||
|
|||
Benchmark* Benchmark::Setup(void (*setup)(const benchmark::State&)) { | |||
Benchmark* Benchmark::Setup(callback_function setup) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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