17class BitNumber :
public boost::totally_ordered<BitNumber<T, WIDTH>>
19 static_assert(std::is_integral<T>::value ==
true,
20 "only integral types are supported");
21 static_assert(
sizeof(T) * 8 > WIDTH,
22 "width has to be less than size of underlying type");
25 static constexpr T
mask = (1 << WIDTH) - 1;
26 static constexpr std::size_t
bits = WIDTH;
29 BitNumber() : mValue(0) {}
31 BitNumber& operator=(T value) { mValue = value &
mask;
return *
this; }
32 T raw()
const {
return mValue; }
34 bool operator<(BitNumber other)
const {
return mValue < other.mValue; }
35 bool operator==(BitNumber other)
const {
return mValue == other.mValue; }