| 42 | RoundRobin(Iterator begin, std::size_t size) : begin_(begin), size_(size) {} |
| 43 | |
| 44 | decltype(auto) next() |
| 45 | { |
| 46 | const auto cur = current_.fetch_add(1, std::memory_order_relaxed); |
| 47 | const auto pos = cur % size_; |
| 48 | return *std::next(begin_, static_cast<std::ptrdiff_t>(pos)); |
| 49 | } |
| 50 | |
| 51 | private: |
| 52 | Iterator begin_; |