aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-03-30 15:52:15 -0700
committerChris Robinson <[email protected]>2022-03-30 15:52:15 -0700
commitabfb584f1493b6295093a73235f1cea77ec15575 (patch)
treeadde2334e6af5880b5fdc8ee74769cd1b7b54dc5 /common
parent4999b5716cfbe95f3e8ed5e9dc3014c3ec8652c8 (diff)
Simplify al::byte
It's just an alias for unsigned char now, and no longer strongly-typed like std::byte.
Diffstat (limited to 'common')
-rw-r--r--common/albyte.h52
1 files changed, 1 insertions, 51 deletions
diff --git a/common/albyte.h b/common/albyte.h
index b871164d..be586869 100644
--- a/common/albyte.h
+++ b/common/albyte.h
@@ -10,57 +10,7 @@ using uint = unsigned int;
namespace al {
-/* The "canonical" way to store raw byte data. Like C++17's std::byte, it's not
- * treated as a character type and does not work with arithmatic ops. Only
- * bitwise ops are allowed.
- */
-enum class byte : unsigned char { };
-
-template<typename T>
-constexpr std::enable_if_t<std::is_integral<T>::value,T>
-to_integer(al::byte b) noexcept { return T(b); }
-
-
-template<typename T>
-constexpr std::enable_if_t<std::is_integral<T>::value,al::byte>
-operator<<(al::byte lhs, T rhs) noexcept { return al::byte(to_integer<uint>(lhs) << rhs); }
-
-template<typename T>
-constexpr std::enable_if_t<std::is_integral<T>::value,al::byte>
-operator>>(al::byte lhs, T rhs) noexcept { return al::byte(to_integer<uint>(lhs) >> rhs); }
-
-template<typename T>
-constexpr std::enable_if_t<std::is_integral<T>::value,al::byte&>
-operator<<=(al::byte &lhs, T rhs) noexcept { lhs = lhs << rhs; return lhs; }
-
-template<typename T>
-constexpr std::enable_if_t<std::is_integral<T>::value,al::byte&>
-operator>>=(al::byte &lhs, T rhs) noexcept { lhs = lhs >> rhs; return lhs; }
-
-#define AL_DECL_OP(op, opeq) \
-template<typename T> \
-constexpr std::enable_if_t<std::is_integral<T>::value,al::byte> \
-operator op (al::byte lhs, T rhs) noexcept \
-{ return al::byte(to_integer<uint>(lhs) op static_cast<uint>(rhs)); } \
- \
-template<typename T> \
-constexpr std::enable_if_t<std::is_integral<T>::value,al::byte&> \
-operator opeq (al::byte &lhs, T rhs) noexcept { lhs = lhs op rhs; return lhs; } \
- \
-constexpr al::byte operator op (al::byte lhs, al::byte rhs) noexcept \
-{ return al::byte(lhs op to_integer<uint>(rhs)); } \
- \
-constexpr al::byte& operator opeq (al::byte &lhs, al::byte rhs) noexcept \
-{ lhs = lhs op rhs; return lhs; }
-
-AL_DECL_OP(|, |=)
-AL_DECL_OP(&, &=)
-AL_DECL_OP(^, ^=)
-
-#undef AL_DECL_OP
-
-constexpr al::byte operator~(al::byte b) noexcept
-{ return al::byte(~to_integer<uint>(b)); }
+using byte = unsigned char;
} // namespace al