| 87 | FL_DISABLE_WARNING_PUSH |
| 88 | FL_DISABLE_WARNING_NULL_DEREFERENCE |
| 89 | void assign(fl::u32 n, bool value) FL_NOEXCEPT { |
| 90 | if (n > _size) { |
| 91 | resize(n); |
| 92 | } |
| 93 | if (value) { |
| 94 | // Set all bits to 1 |
| 95 | if (_blocks && _block_count > 0) { |
| 96 | for (fl::u32 i = 0; i < _block_count; ++i) { |
| 97 | _blocks[i] = static_cast<block_type>(~block_type(0)); |
| 98 | } |
| 99 | // Clear any bits beyond the actual size |
| 100 | if (_size % bits_per_block != 0) { |
| 101 | fl::u32 last_block_idx = (_size - 1) / bits_per_block; |
| 102 | fl::u32 last_bit_pos = (_size - 1) % bits_per_block; |
| 103 | block_type mask = static_cast<block_type>((static_cast<block_type>(1) << (last_bit_pos + 1)) - 1); |
| 104 | _blocks[last_block_idx] &= mask; |
| 105 | } |
| 106 | } |
| 107 | } else { |
| 108 | // Set all bits to 0 |
| 109 | reset(); |
| 110 | } |
| 111 | } |
| 112 | FL_DISABLE_WARNING_POP |
| 113 | |
| 114 | // Resize the bitset |