5namespace di::bit::detail {
6class BitProxyReference {
8 constexpr explicit BitProxyReference(
u8*
byte,
u8 bit_offset) : m_byte(
byte), m_bit_offset(bit_offset) {}
10 constexpr BitProxyReference(BitProxyReference
const&) =
default;
11 constexpr BitProxyReference(BitProxyReference&&) =
default;
13 constexpr auto operator=(
bool value)
const -> BitProxyReference
const& {
15 *m_byte |= (1U << m_bit_offset);
17 *m_byte &= ~(1U << m_bit_offset);
23 constexpr auto operator=(BitProxyReference
const& other)
const -> BitProxyReference
const& {
24 return *
this = bool(other);
27 constexpr operator bool()
const {
return !!(*m_byte & (1U << m_bit_offset)); }
29 constexpr auto operator~()
const ->
bool {
return !bool(*
this); }
31 constexpr auto flip()
const -> BitProxyReference
const& {
32 *m_byte ^= (1U << m_bit_offset);