Skip to content

Commit 6a28f1e

Browse files
biojppmdominichamon
authored andcommitted
Fixture: add non const Setup() and TearDown(). (#285)
* 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.
1 parent 83561f0 commit 6a28f1e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/benchmark/benchmark_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,12 @@ class Fixture: public internal::Benchmark {
709709
this->TearDown(st);
710710
}
711711

712+
// These will be deprecated ...
712713
virtual void SetUp(const State&) {}
713714
virtual void TearDown(const State&) {}
715+
// ... In favor of these.
716+
virtual void SetUp(State& st) { SetUp(const_cast<const State&>(st)); }
717+
virtual void TearDown(State& st) { TearDown(const_cast<const State&>(st)); }
714718

715719
protected:
716720
virtual void BenchmarkCase(State&) = 0;

0 commit comments

Comments
 (0)