mirror of
https://github.com/google/benchmark.git
synced 2025-02-26 19:30:12 +08:00
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.
This commit is contained in:
parent
6ecf8a8e80
commit
858688b845
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user