Combine two macros into one
This commit is contained in:
parent
a478fd4b25
commit
a2ba230e05
@ -27,23 +27,6 @@ template<typename T, REQUIRES(std::is_integral<T>::value)>
|
||||
inline constexpr al::byte operator>>(al::byte lhs, T rhs) noexcept
|
||||
{ return al::byte(to_integer<unsigned int>(lhs) >> rhs); }
|
||||
|
||||
#define AL_DECL_OP(op) \
|
||||
template<typename T, REQUIRES(std::is_integral<T>::value)> \
|
||||
inline constexpr al::byte operator op (al::byte lhs, T rhs) noexcept \
|
||||
{ return al::byte(to_integer<unsigned int>(lhs) op rhs); } \
|
||||
inline constexpr al::byte operator op (al::byte lhs, al::byte rhs) noexcept \
|
||||
{ return al::byte(lhs op to_integer<unsigned int>(rhs)); }
|
||||
|
||||
AL_DECL_OP(|)
|
||||
AL_DECL_OP(&)
|
||||
AL_DECL_OP(^)
|
||||
|
||||
#undef AL_DECL_OP
|
||||
|
||||
inline constexpr al::byte operator~(al::byte b) noexcept
|
||||
{ return al::byte(~to_integer<unsigned int>(b)); }
|
||||
|
||||
|
||||
template<typename T, REQUIRES(std::is_integral<T>::value)>
|
||||
inline al::byte& operator<<=(al::byte &lhs, T rhs) noexcept
|
||||
{ lhs = lhs << rhs; return lhs; }
|
||||
@ -54,8 +37,13 @@ inline al::byte& operator>>=(al::byte &lhs, T rhs) noexcept
|
||||
|
||||
#define AL_DECL_OP(op) \
|
||||
template<typename T, REQUIRES(std::is_integral<T>::value)> \
|
||||
inline constexpr al::byte operator op (al::byte lhs, T rhs) noexcept \
|
||||
{ return al::byte(to_integer<unsigned int>(lhs) op rhs); } \
|
||||
template<typename T, REQUIRES(std::is_integral<T>::value)> \
|
||||
inline al::byte& operator op##= (al::byte &lhs, T rhs) noexcept \
|
||||
{ lhs = lhs op rhs; return lhs; } \
|
||||
inline constexpr al::byte operator op (al::byte lhs, al::byte rhs) noexcept \
|
||||
{ return al::byte(lhs op to_integer<unsigned int>(rhs)); } \
|
||||
inline al::byte& operator op##= (al::byte &lhs, al::byte rhs) noexcept \
|
||||
{ lhs = lhs op rhs; return lhs; }
|
||||
|
||||
@ -65,6 +53,10 @@ AL_DECL_OP(^)
|
||||
|
||||
#undef AL_DECL_OP
|
||||
|
||||
inline constexpr al::byte operator~(al::byte b) noexcept
|
||||
{ return al::byte(~to_integer<unsigned int>(b)); }
|
||||
|
||||
|
||||
template<size_t N>
|
||||
class bitfield {
|
||||
static constexpr size_t bits_per_byte{std::numeric_limits<unsigned char>::digits};
|
||||
|
Loading…
x
Reference in New Issue
Block a user