16
16
17
17
namespace msg ::detail {
18
18
19
- template <std::size_t N> struct smallest_storage {
20
- // select a minimum sized type for indexing into the RLE data blob
21
- static CONSTEVAL auto select_index_storage () {
22
- if constexpr (N <= std::numeric_limits<std::uint8_t >::max ()) {
23
- return std::uint8_t {};
24
- } else if constexpr (N <= std::numeric_limits<std::uint16_t >::max ()) {
25
- return std::uint16_t {};
26
- } else if constexpr (N <= std::numeric_limits<std::uint32_t >::max ()) {
27
- return std::uint32_t {};
28
- } else {
29
- return std::size_t {};
30
- }
31
- }
32
-
33
- using type = decltype(select_index_storage());
34
- };
35
-
36
19
template <std::size_t N>
37
- using smallest_storage_type = typename smallest_storage<N>::type ;
20
+ using smallest_storage_type = decltype(stdx::detail::select_storage<N, void >()) ;
38
21
39
22
// Captures RLE data for decoding and provides a mechanism to
40
23
// get a single-use enumerator to step through bits in the encoded
@@ -204,11 +187,6 @@ struct rle_intersect {
204
187
constexpr explicit rle_intersect (Decoders &&...decoders )
205
188
: decoder_list{std::forward<Decoders>(decoders)...} {}
206
189
207
- constexpr static auto min_chunk (chunk_type const &a, chunk_type const &b)
208
- -> bool {
209
- return a.bit_chunk () < b.bit_chunk ();
210
- }
211
-
212
190
// iterate over set bits, passing them to bool (&f)(auto bit_number).
213
191
// if f returns true, we abort and return true indicating early exit
214
192
// otherwise return false to indicate no early abort of iteration
@@ -221,12 +199,18 @@ struct rle_intersect {
221
199
chunks.push_back (d.make_chunk_enumerator ());
222
200
}
223
201
202
+ // advance all chunks by a number of bits
224
203
auto advance = [&](std::size_t bits) {
225
204
for (auto &c : chunks) {
226
205
c.advance (bits);
227
206
}
228
207
};
229
208
209
+ // comparison of chunk bit counts
210
+ auto min_chunk = [](chunk_type const &a, chunk_type const &b) -> bool {
211
+ return a.bit_chunk () < b.bit_chunk ();
212
+ };
213
+
230
214
std::size_t bit{0 };
231
215
while (bit < num_bits) {
232
216
// the min "bit_chunk" item in the chunk list is the smallest run
0 commit comments