FastLED 3.10.10
Loading...
Searching...
No Matches
bitset.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/variant.h"
5#include "fl/stl/int.h"
8
10#include "fl/stl/move.h"
11#include "fl/stl/noexcept.h"
12
14FL_DISABLE_WARNING(double-promotion)
15FL_DISABLE_WARNING(float-conversion)
16FL_DISABLE_WARNING(sign-conversion)
19
20
21namespace fl {
22
23template <fl::u32 N> class bitset_inlined;
24
25template <fl::u32 N> class bitset_fixed;
26
27class string;
28template <fl::u32 N = 16>
29using bitset = bitset_inlined<N>; // inlined but can go bigger.
30
31
32// TODO: move this to fl/math.h
33// The unsuffixed builtins take `unsigned int`, which is 16-bit on AVR, so a
34// wider argument is routed to the `l`/`ll` variant to keep its high bits.
35// The value is first converted to the same-width unsigned type, so a negative
36// signed value counts only its own bits, not sign-extension bits.
37template<typename IntType>
38inline fl::u8 popcount(IntType value) FL_NO_EXCEPT {
39 typedef typename fl::make_unsigned<IntType>::type U;
40 const U u = static_cast<U>(value);
41 return static_cast<fl::u8>(
42 sizeof(U) <= sizeof(unsigned) ? __builtin_popcount(static_cast<unsigned>(u))
43 : sizeof(U) <= sizeof(unsigned long) ? __builtin_popcountl(static_cast<unsigned long>(u))
44 : __builtin_popcountll(static_cast<unsigned long long>(u)));
45}
46
49template<typename IntType>
50inline fl::u8 countr_zero(IntType value) FL_NO_EXCEPT {
51 typedef typename fl::make_unsigned<IntType>::type U;
52 const U u = static_cast<U>(value);
53 return static_cast<fl::u8>(
54 sizeof(U) <= sizeof(unsigned) ? __builtin_ctz(static_cast<unsigned>(u))
55 : sizeof(U) <= sizeof(unsigned long) ? __builtin_ctzl(static_cast<unsigned long>(u))
56 : __builtin_ctzll(static_cast<unsigned long long>(u)));
57}
58
60template <fl::u32 N> class bitset_fixed {
61 private:
62 FL_STATIC_ASSERT(sizeof(fl::u16) == 2, "u16 should be 2 bytes");
63 static constexpr fl::u32 bits_per_block = 8 * sizeof(fl::u16);
64 static constexpr fl::u32 block_count =
65 (N + bits_per_block - 1) / bits_per_block;
66 using block_type = fl::u16;
67
68 // Underlying blocks storing bits
69 block_type _blocks[block_count];
70
71 public:
72 struct Proxy {
73 bitset_fixed &_bitset;
74 fl::u32 _pos;
75
76 Proxy(bitset_fixed &bitset, fl::u32 pos) FL_NO_EXCEPT : _bitset(bitset), _pos(pos) {}
77
78 Proxy &operator=(bool value) FL_NO_EXCEPT {
79 _bitset.set(_pos, value);
80 return *this;
81 }
82
83 operator bool() const FL_NO_EXCEPT { return _bitset.test(_pos); }
84 };
85
86 Proxy operator[](fl::u32 pos) FL_NO_EXCEPT { return Proxy(*this, pos); }
87
89 constexpr bitset_fixed() FL_NO_EXCEPT : _blocks{} {}
90
91 void to_string(string* dst) const FL_NO_EXCEPT {
92 detail::to_string(_blocks, N, dst);
93 }
94
96 void reset() FL_NO_EXCEPT {
97 for (fl::u32 i = 0; i < block_count; ++i) {
98 _blocks[i] = 0;
99 }
100 }
101
103 bitset_fixed &set(fl::u32 pos, bool value = true) FL_NO_EXCEPT {
104 if (pos < N) {
105 const fl::u32 idx = pos / bits_per_block;
106 const fl::u32 off = pos % bits_per_block;
107 if (value) {
108 _blocks[idx] |= (block_type(1) << off);
109 } else {
110 _blocks[idx] &= ~(block_type(1) << off);
111 }
112 }
113 return *this;
114 }
115
116 void assign(fl::size n, bool value) FL_NO_EXCEPT {
117 if (n > N) {
118 n = N;
119 }
120 for (fl::size i = 0; i < n; ++i) {
121 set(i, value);
122 }
123 }
124
126 bitset_fixed &reset(fl::u32 pos) FL_NO_EXCEPT { return set(pos, false); }
127
129 bitset_fixed &flip(fl::u32 pos) FL_NO_EXCEPT {
130 if (pos < N) {
131 const fl::u32 idx = pos / bits_per_block;
132 const fl::u32 off = pos % bits_per_block;
133 _blocks[idx] ^= (block_type(1) << off);
134 }
135 return *this;
136 }
137
139 bitset_fixed &flip() FL_NO_EXCEPT {
140 for (fl::u32 i = 0; i < block_count; ++i) {
141 _blocks[i] = ~_blocks[i];
142 }
143 // Mask out unused high bits in the last block
144 if (N % bits_per_block != 0) {
145 const fl::u32 extra = bits_per_block - (N % bits_per_block);
146 _blocks[block_count - 1] &= (~block_type(0) >> extra);
147 }
148 return *this;
149 }
150
152 bool test(fl::u32 pos) const FL_NO_EXCEPT {
153 if (pos < N) {
154 const fl::u32 idx = pos / bits_per_block;
155 const fl::u32 off = pos % bits_per_block;
156 return (_blocks[idx] >> off) & 1;
157 }
158 return false;
159 }
160
162 bool operator[](fl::u32 pos) const FL_NO_EXCEPT { return test(pos); }
163
165 fl::u32 count() const FL_NO_EXCEPT {
166 fl::u32 cnt = 0;
167 // Count bits in all complete blocks
168 for (fl::u32 i = 0; i + 1 < block_count; ++i) {
169 cnt += fl::popcount(_blocks[i]);
170 }
171
172 // For the last block, we need to be careful about counting only valid
173 // bits
174 if (block_count > 0) {
175 block_type last_block = _blocks[block_count - 1];
176 // If N is not a multiple of bits_per_block, mask out the unused
177 // bits
178 if (N % bits_per_block != 0) {
179 const fl::u32 valid_bits = N % bits_per_block;
180 // Create a mask with only the valid bits set to 1
181 block_type mask = (valid_bits == bits_per_block)
182 ? static_cast<block_type>(~block_type(0))
183 : ((block_type(1) << valid_bits) - 1);
184 last_block &= mask;
185 }
186 cnt += fl::popcount(last_block);
187 }
188
189 return cnt;
190 }
191
193 bool any() const FL_NO_EXCEPT { return count() > 0; }
194 bool none() const FL_NO_EXCEPT { return count() == 0; }
195 bool all() const FL_NO_EXCEPT {
196 if (N == 0)
197 return true;
198
199 // Check all complete blocks
200 for (fl::u32 i = 0; i < block_count - 1; ++i) {
201 if (_blocks[i] != ~block_type(0)) {
202 return false;
203 }
204 }
205
206 // Check the last block
207 if (block_count > 0) {
208 block_type mask;
209 if (N % bits_per_block != 0) {
210 // Create a mask for the valid bits in the last block
211 mask = (block_type(1) << (N % bits_per_block)) - 1;
212 } else {
213 mask = static_cast<block_type>(~block_type(0));
214 }
215
216 if ((_blocks[block_count - 1] & mask) != mask) {
217 return false;
218 }
219 }
220
221 return true;
222 }
223
225 bitset_fixed &operator&=(const bitset_fixed &other) FL_NO_EXCEPT {
226 for (fl::u32 i = 0; i < block_count; ++i) {
227 _blocks[i] &= other._blocks[i];
228 }
229 return *this;
230 }
232 bitset_fixed &operator|=(const bitset_fixed &other) FL_NO_EXCEPT {
233 for (fl::u32 i = 0; i < block_count; ++i) {
234 _blocks[i] |= other._blocks[i];
235 }
236 return *this;
237 }
239 bitset_fixed &operator^=(const bitset_fixed &other) FL_NO_EXCEPT {
240 for (fl::u32 i = 0; i < block_count; ++i) {
241 _blocks[i] ^= other._blocks[i];
242 }
243 return *this;
244 }
245
247 constexpr fl::u32 size() const FL_NO_EXCEPT { return N; }
248
253 fl::i32 find_first(bool test_value, fl::u32 offset = 0) const FL_NO_EXCEPT {
254 // If offset is beyond our size, no match possible
255 if (offset >= N) {
256 return -1;
257 }
258
259 // Calculate which block to start from
260 fl::u32 start_block = offset / bits_per_block;
261 fl::u32 start_bit = offset % bits_per_block;
262
263 for (fl::u32 block_idx = start_block; block_idx < block_count; ++block_idx) {
264 block_type current_block = _blocks[block_idx];
265
266 // For the last block, we need to mask out unused bits
267 if (block_idx == block_count - 1 && N % bits_per_block != 0) {
268 const fl::u32 valid_bits = N % bits_per_block;
269 block_type mask = (valid_bits == bits_per_block)
270 ? static_cast<block_type>(~block_type(0))
271 : ((block_type(1) << valid_bits) - 1);
272 current_block &= mask;
273 }
274
275 // If looking for false bits, invert the block
276 if (!test_value) {
277 current_block = ~current_block;
278 }
279
280 // For the first block, mask out bits before the offset
281 if (block_idx == start_block && start_bit > 0) {
282 current_block &= ~((block_type(1) << start_bit) - 1);
283 }
284
285 // If there are any matching bits in this block
286 if (current_block != 0) {
287 // Find the first set bit
288 fl::u32 bit_pos = fl::countr_zero(current_block);
289 fl::u32 absolute_pos = block_idx * bits_per_block + bit_pos;
290
291 // Make sure we haven't gone past the end of the bitset
292 if (absolute_pos < N) {
293 return static_cast<fl::i32>(absolute_pos);
294 }
295 }
296 }
297
298 return -1; // No matching bit found
299 }
300
306 fl::i32 find_run(bool test_value, fl::u32 min_length, fl::u32 offset = 0) const FL_NO_EXCEPT {
307 fl::u32 run_start = offset;
308 fl::u32 run_length = 0;
309
310 for (fl::u32 i = offset; i < N && run_length < min_length; ++i) {
311 bool current_bit = test(i);
312 if (current_bit != test_value) {
313 run_length = 0;
314 if (i + 1 < N) {
315 run_start = i + 1;
316 }
317 } else {
318 ++run_length;
319 }
320 }
321
322 if (run_length >= min_length) {
323 return static_cast<fl::i32>(run_start);
324 }
325
326 return -1; // No run found
327 }
328
330 bool operator==(const bitset_fixed &other) const FL_NO_EXCEPT {
331 for (fl::u32 i = 0; i < block_count; ++i) {
332 if (_blocks[i] != other._blocks[i]) {
333 return false;
334 }
335 }
336 return true;
337 }
338
339 bool operator!=(const bitset_fixed &other) const FL_NO_EXCEPT {
340 return !(*this == other);
341 }
342
344 bool operator<(const bitset_fixed &other) const FL_NO_EXCEPT {
345 for (fl::i32 i = static_cast<fl::i32>(block_count) - 1; i >= 0; --i) {
346 if (_blocks[i] < other._blocks[i]) {
347 return true;
348 }
349 if (_blocks[i] > other._blocks[i]) {
350 return false;
351 }
352 }
353 return false;
354 }
355
356 bool operator<=(const bitset_fixed &other) const FL_NO_EXCEPT {
357 return *this < other || *this == other;
358 }
359
360 bool operator>(const bitset_fixed &other) const FL_NO_EXCEPT {
361 return other < *this;
362 }
363
364 bool operator>=(const bitset_fixed &other) const FL_NO_EXCEPT {
365 return other <= *this;
366 }
367
369 friend bitset_fixed operator&(bitset_fixed lhs,
370 const bitset_fixed &rhs) FL_NO_EXCEPT {
371 return lhs &= rhs;
372 }
373 friend bitset_fixed operator|(bitset_fixed lhs,
374 const bitset_fixed &rhs) FL_NO_EXCEPT {
375 return lhs |= rhs;
376 }
377 friend bitset_fixed operator^(bitset_fixed lhs,
378 const bitset_fixed &rhs) FL_NO_EXCEPT {
379 return lhs ^= rhs;
380 }
381 friend bitset_fixed operator~(bitset_fixed bs) FL_NO_EXCEPT { return bs.flip(); }
382};
383
387template <fl::u32 N = 16> // Default size is 16 bits, or 2 bytes
388class bitset_inlined {
389 private:
390 // Either store a fixed Bitset<N> or a dynamic Bitset
391 using fixed_bitset = bitset_fixed<N>;
392 variant<fixed_bitset, bitset_dynamic> _storage;
393
394 public:
395 struct Proxy {
396 bitset_inlined &_bitset;
397 fl::u32 _pos;
398
399 Proxy(bitset_inlined &bitset, fl::u32 pos) FL_NO_EXCEPT
400 : _bitset(bitset), _pos(pos) {}
401
402 Proxy &operator=(bool value) FL_NO_EXCEPT {
403 _bitset.set(_pos, value);
404 return *this;
405 }
406
407 operator bool() const FL_NO_EXCEPT { return _bitset.test(_pos); }
408 };
409
410 Proxy operator[](fl::u32 pos) FL_NO_EXCEPT { return Proxy(*this, pos); }
411
413 bitset_inlined() FL_NO_EXCEPT : _storage(fixed_bitset()) {}
414 bitset_inlined(fl::size size) FL_NO_EXCEPT : _storage(fixed_bitset()) {
415 if (size > N) {
416 _storage = bitset_dynamic(size);
417 }
418 }
419 bitset_inlined(const bitset_inlined &other) FL_NO_EXCEPT : _storage(other._storage) {}
420 bitset_inlined(bitset_inlined &&other) FL_NO_EXCEPT
421 : _storage(fl::move(other._storage)) {}
422 bitset_inlined &operator=(const bitset_inlined &other) FL_NO_EXCEPT {
423 if (this != &other) {
424 _storage = other._storage;
425 }
426 return *this;
427 }
428 bitset_inlined &operator=(bitset_inlined &&other) FL_NO_EXCEPT {
429 if (this != &other) {
430 _storage = fl::move(other._storage);
431 }
432 return *this;
433 }
434
436 void reset() FL_NO_EXCEPT {
437 if (_storage.template is<fixed_bitset>()) {
438 _storage.template ptr<fixed_bitset>()->reset();
439 } else {
440 _storage.template ptr<bitset_dynamic>()->reset();
441 }
442 }
443
444 void assign(fl::size n, bool value) FL_NO_EXCEPT {
445 resize(n);
446 if (_storage.template is<fixed_bitset>()) {
447 _storage.template ptr<fixed_bitset>()->assign(n, value);
448 } else {
449 _storage.template ptr<bitset_dynamic>()->assign(n, value);
450 }
451 }
452
453
454
456 void resize(fl::u32 new_size) FL_NO_EXCEPT {
457 if (new_size <= N) {
458 // If we're already using the fixed Bitset, nothing to do
459 if (_storage.template is<bitset_dynamic>()) {
460 // Convert back to fixed Bitset
461 fixed_bitset fixed;
462 bitset_dynamic *dynamic =
463 _storage.template ptr<bitset_dynamic>();
464
465 // Copy bits from dynamic to fixed
466 for (fl::u32 i = 0; i < N && i < dynamic->size(); ++i) {
467 if (dynamic->test(i)) {
468 fixed.set(i);
469 }
470 }
471
472 _storage = fixed;
473 }
474 } else {
475 // Need to use dynamic Bitset
476 if (_storage.template is<fixed_bitset>()) {
477 // Convert from fixed to dynamic
478 bitset_dynamic dynamic(new_size);
479 fixed_bitset *fixed = _storage.template ptr<fixed_bitset>();
480
481 // Copy bits from fixed to dynamic
482 for (fl::u32 i = 0; i < N; ++i) {
483 if (fixed->test(i)) {
484 dynamic.set(i);
485 }
486 }
487
488 _storage = dynamic;
489 } else {
490 // Already using dynamic, just resize
491 _storage.template ptr<bitset_dynamic>()->resize(new_size);
492 }
493 }
494 }
495
497 bitset_inlined &set(fl::u32 pos, bool value = true) FL_NO_EXCEPT {
498 if (pos >= N && _storage.template is<fixed_bitset>()) {
499 resize(pos + 1);
500 }
501
502 if (_storage.template is<fixed_bitset>()) {
503 if (pos < N) {
504 _storage.template ptr<fixed_bitset>()->set(pos, value);
505 }
506 } else {
507 if (pos >= _storage.template ptr<bitset_dynamic>()->size()) {
508 _storage.template ptr<bitset_dynamic>()->resize(pos + 1);
509 }
510 _storage.template ptr<bitset_dynamic>()->set(pos, value);
511 }
512 return *this;
513 }
514
516 bitset_inlined &reset(fl::u32 pos) FL_NO_EXCEPT { return set(pos, false); }
517
519 bitset_inlined &flip(fl::u32 pos) FL_NO_EXCEPT {
520 if (pos >= N && _storage.template is<fixed_bitset>()) {
521 resize(pos + 1);
522 }
523
524 if (_storage.template is<fixed_bitset>()) {
525 if (pos < N) {
526 _storage.template ptr<fixed_bitset>()->flip(pos);
527 }
528 } else {
529 if (pos >= _storage.template ptr<bitset_dynamic>()->size()) {
530 _storage.template ptr<bitset_dynamic>()->resize(pos + 1);
531 }
532 _storage.template ptr<bitset_dynamic>()->flip(pos);
533 }
534 return *this;
535 }
536
538 bitset_inlined &flip() FL_NO_EXCEPT {
539 if (_storage.template is<fixed_bitset>()) {
540 _storage.template ptr<fixed_bitset>()->flip();
541 } else {
542 _storage.template ptr<bitset_dynamic>()->flip();
543 }
544 return *this;
545 }
546
548 void push_back() FL_NO_EXCEPT {
549 fl::u32 new_size = size() + 1;
550 resize(new_size);
551 }
552
554 template<typename... Args>
555 void emplace_back(Args&&...) FL_NO_EXCEPT {
556 push_back(); // bitset bits are bool, just expand
557 }
558
560 void pop_back() FL_NO_EXCEPT {
561 if (size() > 0) {
562 resize(size() - 1);
563 }
564 }
565
567 bool test(fl::u32 pos) const FL_NO_EXCEPT {
568 if (_storage.template is<fixed_bitset>()) {
569 return pos < N ? _storage.template ptr<fixed_bitset>()->test(pos)
570 : false;
571 } else {
572 return _storage.template ptr<bitset_dynamic>()->test(pos);
573 }
574 }
575
577 bool operator[](fl::u32 pos) const FL_NO_EXCEPT { return test(pos); }
578
580 fl::u32 count() const FL_NO_EXCEPT {
581 if (_storage.template is<fixed_bitset>()) {
582 return _storage.template ptr<fixed_bitset>()->count();
583 } else {
584 return _storage.template ptr<bitset_dynamic>()->count();
585 }
586 }
587
589 bool any() const FL_NO_EXCEPT {
590 if (_storage.template is<fixed_bitset>()) {
591 return _storage.template ptr<fixed_bitset>()->any();
592 } else {
593 return _storage.template ptr<bitset_dynamic>()->any();
594 }
595 }
596
597 bool none() const FL_NO_EXCEPT {
598 if (_storage.template is<fixed_bitset>()) {
599 return _storage.template ptr<fixed_bitset>()->none();
600 } else {
601 return _storage.template ptr<bitset_dynamic>()->none();
602 }
603 }
604
605 bool all() const FL_NO_EXCEPT {
606 if (_storage.template is<fixed_bitset>()) {
607 return _storage.template ptr<fixed_bitset>()->all();
608 } else {
609 return _storage.template ptr<bitset_dynamic>()->all();
610 }
611 }
612
614 fl::u32 size() const FL_NO_EXCEPT {
615 if (_storage.template is<fixed_bitset>()) {
616 return N;
617 } else {
618 return _storage.template ptr<bitset_dynamic>()->size();
619 }
620 }
621
623 void to_string(string* dst) const FL_NO_EXCEPT {
624 if (_storage.template is<fixed_bitset>()) {
625 _storage.template ptr<fixed_bitset>()->to_string(dst);
626 } else {
627 _storage.template ptr<bitset_dynamic>()->to_string(dst);
628 }
629 }
630
635 fl::i32 find_first(bool test_value, fl::u32 offset = 0) const FL_NO_EXCEPT {
636 if (_storage.template is<fixed_bitset>()) {
637 return _storage.template ptr<fixed_bitset>()->find_first(test_value, offset);
638 } else {
639 return _storage.template ptr<bitset_dynamic>()->find_first(test_value, offset);
640 }
641 }
642
644 friend bitset_inlined operator~(const bitset_inlined &bs) FL_NO_EXCEPT {
645 bitset_inlined result = bs;
646 result.flip();
647 return result;
648 }
649
650 friend bitset_inlined operator&(const bitset_inlined &lhs,
651 const bitset_inlined &rhs) FL_NO_EXCEPT {
652 bitset_inlined result = lhs;
653
654 if (result._storage.template is<fixed_bitset>() &&
655 rhs._storage.template is<fixed_bitset>()) {
656 // Both are fixed, use the fixed implementation
657 *result._storage.template ptr<fixed_bitset>() &=
658 *rhs._storage.template ptr<fixed_bitset>();
659 } else {
660 // At least one is dynamic, handle bit by bit
661 fl::u32 min_size =
662 result.size() < rhs.size() ? result.size() : rhs.size();
663 for (fl::u32 i = 0; i < min_size; ++i) {
664 result.set(i, result.test(i) && rhs.test(i));
665 }
666 // Clear any bits beyond the size of rhs
667 for (fl::u32 i = min_size; i < result.size(); ++i) {
668 result.reset(i);
669 }
670 }
671
672 return result;
673 }
674
675 friend bitset_inlined operator|(const bitset_inlined &lhs,
676 const bitset_inlined &rhs) FL_NO_EXCEPT {
677 bitset_inlined result = lhs;
678
679 if (result._storage.template is<fixed_bitset>() &&
680 rhs._storage.template is<fixed_bitset>()) {
681 // Both are fixed, use the fixed implementation
682 *result._storage.template ptr<fixed_bitset>() |=
683 *rhs._storage.template ptr<fixed_bitset>();
684 } else {
685 // At least one is dynamic, handle bit by bit
686 fl::u32 max_size =
687 result.size() > rhs.size() ? result.size() : rhs.size();
688
689 // Resize if needed
690 if (result.size() < max_size) {
691 result.resize(max_size);
692 }
693
694 // Set bits from rhs
695 for (fl::u32 i = 0; i < rhs.size(); ++i) {
696 if (rhs.test(i)) {
697 result.set(i);
698 }
699 }
700 }
701
702 return result;
703 }
704
705 friend bitset_inlined operator^(const bitset_inlined &lhs,
706 const bitset_inlined &rhs) FL_NO_EXCEPT {
707 bitset_inlined result = lhs;
708
709 if (result._storage.template is<fixed_bitset>() &&
710 rhs._storage.template is<fixed_bitset>()) {
711 // Both are fixed, use the fixed implementation
712 *result._storage.template ptr<fixed_bitset>() ^=
713 *rhs._storage.template ptr<fixed_bitset>();
714 } else {
715 // At least one is dynamic, handle bit by bit
716 fl::u32 max_size =
717 result.size() > rhs.size() ? result.size() : rhs.size();
718
719 // Resize if needed
720 if (result.size() < max_size) {
721 result.resize(max_size);
722 }
723
724 // XOR bits from rhs
725 for (fl::u32 i = 0; i < rhs.size(); ++i) {
726 result.set(i, result.test(i) != rhs.test(i));
727 }
728 }
729
730 return result;
731 }
732
734 bool operator==(const bitset_inlined &other) const FL_NO_EXCEPT {
735 if (size() != other.size()) {
736 return false;
737 }
738 for (fl::u32 i = 0; i < size(); ++i) {
739 if (test(i) != other.test(i)) {
740 return false;
741 }
742 }
743 return true;
744 }
745
746 bool operator!=(const bitset_inlined &other) const FL_NO_EXCEPT {
747 return !(*this == other);
748 }
749
751 bool operator<(const bitset_inlined &other) const FL_NO_EXCEPT {
752 fl::u32 min_size = size() < other.size() ? size() : other.size();
753 for (fl::u32 i = min_size; i > 0; --i) {
754 bool this_bit = test(i - 1);
755 bool other_bit = other.test(i - 1);
756 if (this_bit != other_bit) {
757 return !this_bit; // false < true
758 }
759 }
760 // All common bits are equal, shorter is less
761 return size() < other.size();
762 }
763
764 bool operator<=(const bitset_inlined &other) const FL_NO_EXCEPT {
765 return *this < other || *this == other;
766 }
767
768 bool operator>(const bitset_inlined &other) const FL_NO_EXCEPT {
769 return other < *this;
770 }
771
772 bool operator>=(const bitset_inlined &other) const FL_NO_EXCEPT {
773 return other <= *this;
774 }
775};
776
777} // namespace fl
778
uint8_t pos
Definition Blur.ino:11
ClearFlags & operator|=(ClearFlags &a, ClearFlags b) FL_NO_EXCEPT
Enable bitwise OR assignment for ClearFlags.
Definition FastLED.h:684
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition move.h:30
void to_string(const fl::u16 *bit_data, fl::u32 bit_count, string *dst) FL_NO_EXCEPT
Definition bitset.cpp.hpp:9
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition s16x16x4.h:30
unsigned char u8
Definition stdint.h:132
constexpr int type_rank< T >::value
FASTLED_FORCE_INLINE CRGB operator&(const CRGB &p1, const CRGB &p2) FL_NO_EXCEPT
Combine two CRGB objects, taking the smallest value of each channel.
Definition crgb.h:794
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs) FL_NO_EXCEPT
Check if two CRGB objects have the same color data.
Definition crgb.h:740
FASTLED_FORCE_INLINE CRGB operator|(const CRGB &p1, const CRGB &p2) FL_NO_EXCEPT
Combine two CRGB objects, taking the largest value of each channel.
Definition crgb.h:802
FASTLED_FORCE_INLINE bool operator>(const CRGB &lhs, const CRGB &rhs) FL_NO_EXCEPT
Check if the sum of the color channels in one CRGB object is greater than another.
Definition crgb.h:761
FASTLED_FORCE_INLINE bool operator<=(const CRGB &lhs, const CRGB &rhs) FL_NO_EXCEPT
Check if the sum of the color channels in one CRGB object is less than or equal to another.
Definition crgb.h:779
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
string to_string(T value) FL_NO_EXCEPT
Definition string.h:459
FASTLED_FORCE_INLINE bool operator!=(const CRGB &lhs, const CRGB &rhs) FL_NO_EXCEPT
Check if two CRGB objects do not have the same color data.
Definition crgb.h:746
FASTLED_FORCE_INLINE bool operator>=(const CRGB &lhs, const CRGB &rhs) FL_NO_EXCEPT
Check if the sum of the color channels in one CRGB object is greater than or equal to another.
Definition crgb.h:770
FASTLED_FORCE_INLINE bool operator<(const CRGB &lhs, const CRGB &rhs) FL_NO_EXCEPT
Check if the sum of the color channels in one CRGB object is less than another.
Definition crgb.h:752
Base definition for an LED controller.
#define FL_DISABLE_WARNING(warning)
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FL_STATIC_ASSERT(...)
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
#define FL_NO_EXCEPT
#define FL_DISABLE_WARNING_FLOAT_CONVERSION
Portable compile-time assertion wrapper.