Commit 858688b8 by Eric Fiselier

Ensure std::iterator_traits<StateIterator> instantiates.

Due to ADL lookup performed on the begin and end functions of `for (auto _ : State)`, std::iterator_traits may get incidentally instantiated. This patch ensures the library can tolerate that.
parent 6ecf8a8e
......@@ -669,6 +669,7 @@ struct State::StateIterator {
typedef Value value_type;
typedef Value reference;
typedef Value pointer;
typedef std::ptrdiff_t difference_type;
private:
friend class State;
......
......@@ -126,4 +126,10 @@ void BM_RangedFor(benchmark::State& state) {
}
BENCHMARK(BM_RangedFor);
// Ensure that StateIterator provides all the necessary typedefs required to
// instantiate std::iterator_traits.
static_assert(std::is_same<
typename std::iterator_traits<benchmark::State::StateIterator>::value_type,
typename benchmark::State::StateIterator::value_type>::value, "");
BENCHMARK_MAIN();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment