@@ -101,13 +101,16 @@ class bitset {
101
101
return lhs;
102
102
}
103
103
104
+ using iter_arg_t = conditional_t <std::is_enum_v<decltype (Size)>,
105
+ decltype (Size), std::size_t >;
106
+
104
107
template <typename F> constexpr auto for_each (F &&f) const -> F {
105
108
std::size_t i = 0 ;
106
109
for (auto e : storage) {
107
110
while (e != 0 ) {
108
111
auto const offset = static_cast <std::size_t >(countr_zero (e));
109
112
e &= static_cast <elem_t >(~(bit << offset));
110
- f (i + offset);
113
+ f (static_cast < iter_arg_t >( i + offset) );
111
114
}
112
115
i += std::numeric_limits<elem_t >::digits;
113
116
}
@@ -124,7 +127,8 @@ class bitset {
124
127
while (e != 0 ) {
125
128
auto const offset = static_cast <std::size_t >(countr_zero (e));
126
129
e &= static_cast <elem_t >(~(bit << offset));
127
- init = r (std::move (init), f (i + offset));
130
+ init =
131
+ r (std::move (init), f (static_cast <iter_arg_t >(i + offset)));
128
132
}
129
133
i += std::numeric_limits<elem_t >::digits;
130
134
}
@@ -440,8 +444,8 @@ constexpr auto for_each(F &&f, bitset<M, S> const &...bs) -> F {
440
444
}
441
445
442
446
template <typename T, typename F, typename R, auto M, typename ... S>
443
- constexpr auto transform_reduce (F &&f, R &&r, T init,
444
- bitset<M, S> const &...bs) -> T {
447
+ [[nodiscard]] constexpr auto transform_reduce (F &&f, R &&r, T init,
448
+ bitset<M, S> const &...bs) -> T {
445
449
if constexpr (sizeof ...(bs) == 1 ) {
446
450
return (bs.transform_reduce (std::forward<F>(f), std::forward<R>(r),
447
451
std::move (init)),
0 commit comments