98 void operator()(It first, It last, Getter getter = Getter{})
const {
100 constexpr auto passes = N / Bit;
102 using value_type =
typename std::iterator_traits<It>::value_type;
103 std::vector<value_type> aux(std::distance(first, last));
105 auto part = [getter = std::move(getter)](
auto from,
auto to,
auto out,
auto start) {
106 constexpr auto mask = (1 << Bit) - 1;
107 constexpr auto buckets = 1 << Bit;
110 std::size_t count[buckets]{};
112 for(
auto it = from; it != to; ++it) {
113 ++count[(getter(*it) >> start) & mask];
117 std::size_t index[buckets]{};
119 for(std::size_t pos{}, end = buckets - 1u; pos < end; ++pos) {
120 index[pos + 1u] = index[pos] + count[pos];
123 for(
auto it = from; it != to; ++it) {
124 out[index[(getter(*it) >> start) & mask]++] = std::move(*it);
128 for(std::size_t pass = 0; pass < (passes & ~1); pass += 2) {
129 part(first, last, aux.begin(), pass * Bit);
130 part(aux.begin(), aux.end(), first, (pass + 1) * Bit);
133 if constexpr(passes & 1) {
134 part(first, last, aux.begin(), (passes - 1) * Bit);
135 std::move(aux.begin(), aux.end(), first);