| 3951 | } |
| 3952 | |
| 3953 | static void pipeline_cpp20_std_ranges(bm::State &state) { |
| 3954 | std::uint64_t sum = 0, count = 0; |
| 3955 | for (auto _ : state) { |
| 3956 | auto pipeline = // |
| 3957 | std::views::iota(pipe_start, pipe_end + 1) | // |
| 3958 | std::views::filter(not_fn(is_power_of_two)) | // |
| 3959 | std::views::filter(not_fn(is_power_of_three)) | // |
| 3960 | std::views::transform([](std::uint64_t x) { return prime_factors_view(x); }) | // |
| 3961 | std::views::join; |
| 3962 | |
| 3963 | // Interestingly, STL still struggles with non-homogeneous ranges, |
| 3964 | // if the `begin` and `end` iterators are of different types: |
| 3965 | // |
| 3966 | // std::uint64_t sum = std::accumulate( |
| 3967 | // pipeline.begin(), pipeline.end(), std::uint64_t{0}); |
| 3968 | // |
| 3969 | sum = 0, count = 0; |
| 3970 | for (std::uint64_t factor : pipeline) sum += factor, count++; |
| 3971 | if (count != 84 || sum != 645) state.SkipWithError("Incorrect result"); |
| 3972 | } |
| 3973 | } |
| 3974 | |
| 3975 | BENCHMARK(pipeline_cpp20_std_ranges); |
| 3976 | #endif // defined(__cpp_lib_ranges) |
nothing calls this directly
no test coverage detected