This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<random_access_range range_type> | |
| auto get_chunks(range_type rng, int n_chunks) | |
| { | |
| using begin_t = decltype(ranges::begin(rng)); | |
| using end_t = decltype(ranges::end(rng)); | |
| using chunk_t = subrange<begin_t, end_t>; | |
| vector<chunk_t> chunks(n_chunks); | |
| size_t offset = 0; | |
| size_t container_size = rng.end() - rng.begin(); | |
| size_t count = container_size / n_chunks + container_size % n_chunks; |