FastLED 3.9.15
Loading...
Searching...
No Matches

◆ operator&

template<uint32_t N = 256>
BitsetInlined operator& ( const BitsetInlined< N > & lhs,
const BitsetInlined< N > & rhs )
friend

Definition at line 445 of file bitset.h.

446 {
448
449 if (result._storage.template is<fixed_bitset>() &&
450 rhs._storage.template is<fixed_bitset>()) {
451 // Both are fixed, use the fixed implementation
452 *result._storage.template ptr<fixed_bitset>() &=
453 *rhs._storage.template ptr<fixed_bitset>();
454 } else {
455 // At least one is dynamic, handle bit by bit
457 result.size() < rhs.size() ? result.size() : rhs.size();
458 for (uint32_t i = 0; i < min_size; ++i) {
459 result.set(i, result.test(i) && rhs.test(i));
460 }
461 // Clear any bits beyond the size of rhs
462 for (uint32_t i = min_size; i < result.size(); ++i) {
463 result.reset(i);
464 }
465 }
466
467 return result;
468 }
void reset() noexcept
Resets all bits to zero.
Definition bitset.h:273
bool test(uint32_t pos) const noexcept
Tests whether the bit at position pos is set.
Definition bitset.h:383
BitsetInlined & set(uint32_t pos, bool value=true)
Sets or clears the bit at position pos.
Definition bitset.h:332
uint32_t size() const noexcept
Size of the Bitset (number of bits).
Definition bitset.h:430
Variant< fixed_bitset, bitset_dynamic > _storage
Definition bitset.h:229
A Bitset implementation with inline storage that can grow if needed.
Definition bitset.h:225