Skip to content

Commit

Permalink
Fixture: add non const Setup() and TearDown(). (#285)
Browse files Browse the repository at this point in the history
* Fixture: add non const Setup() and TearDown().

This allows write-access to the State variable, which is important in
upcoming user-defined counter functionality.

* Fix const placement in the Fixture methods.

* Fixture: use const_cast instead of static_cast.
  • Loading branch information
biojppm authored and dominichamon committed Sep 1, 2016
1 parent 83561f0 commit 6a28f1e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/benchmark/benchmark_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,12 @@ class Fixture: public internal::Benchmark {
this->TearDown(st);
}

// These will be deprecated ...
virtual void SetUp(const State&) {}
virtual void TearDown(const State&) {}
// ... In favor of these.
virtual void SetUp(State& st) { SetUp(const_cast<const State&>(st)); }
virtual void TearDown(State& st) { TearDown(const_cast<const State&>(st)); }

protected:
virtual void BenchmarkCase(State&) = 0;
Expand Down

0 comments on commit 6a28f1e

Please sign in to comment.