std::copy with a lazy range which does static cast. Should be the same performance as std::copy with differently typed iterators
| 96 | // std::copy with a lazy range which does static cast. |
| 97 | // Should be the same performance as std::copy with differently typed iterators |
| 98 | void lazy_copy_converting(benchmark::State& state) { |
| 99 | auto source = generate_junk<int64_t>(kSize); |
| 100 | std::vector<int32_t> target(kSize); |
| 101 | auto lazy_range = internal::MakeLazyRange( |
| 102 | [&source](int64_t index) { return static_cast<int32_t>(source[index]); }, |
| 103 | source.size()); |
| 104 | |
| 105 | for (auto _ : state) { |
| 106 | std::copy(lazy_range.begin(), lazy_range.end(), target.begin()); |
| 107 | } |
| 108 | state.SetItemsProcessed(state.iterations() * kSize); |
| 109 | } |
| 110 | |
| 111 | BENCHMARK(lazy_copy_converting); |
| 112 |
nothing calls this directly
no test coverage detected