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.
diff --git a/include/benchmark/benchmark_api.h b/include/benchmark/benchmark_api.h
index 592ed63..2357e88 100644
--- a/include/benchmark/benchmark_api.h
+++ b/include/benchmark/benchmark_api.h
@@ -709,8 +709,12 @@
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;