Files
Persson-dev 6f667deece
All checks were successful
Linux arm64 / Build (push) Successful in 15s
add BitField
2025-06-30 12:08:16 +02:00

38 lines
613 B
C++

#pragma once
#include <cstdint>
namespace sp {
template <typename T, std::size_t BitSize>
class BitField {
private:
static constexpr int BITS_IN_CHAR = 8;
static_assert(sizeof(T) * BITS_IN_CHAR > BitSize, "The bit count must be lower than the actual type size !");
T m_Data;
public:
BitField() : m_Data{} {};
BitField(T a_Data) : m_Data(a_Data) {}
BitField& operator=(T a_Data) {
m_Data = a_Data;
return *this;
}
constexpr std::size_t GetBitSize() const {
return BitSize;
}
T& operator*() {
return m_Data;
}
const T& operator*() const {
return m_Data;
}
};
} // namespace sp