style: use tab replace spaces

every one could change the length of tab but not of space
This commit is contained in:
Wankupi
2024-07-23 18:46:21 +08:00
parent 9038750dbe
commit 80ff0d5682
12 changed files with 455 additions and 421 deletions

View File

@ -3,127 +3,128 @@
namespace dark {
using dark::concepts::bit_match;
using dark::concepts::bit_type;
using dark::concepts::int_type;
using dark::concepts::bit_match;
template <typename _Tp>
constexpr auto cast(const _Tp& value) {
return static_cast <max_size_t> (value);
template<typename _Tp>
constexpr auto cast(const _Tp &value) {
return static_cast<max_size_t>(value);
}
template <typename _Tp, typename _Up>
template<typename _Tp, typename _Up>
consteval auto get_common_length() -> std::size_t {
static_assert(bit_match <_Tp, _Up>);
if constexpr (bit_type <_Tp>) {
return _Tp::_Bit_Len;
} else {
static_assert(bit_type <_Up>, "Invalid common length");
return _Up::_Bit_Len;
}
static_assert(bit_match<_Tp, _Up>);
if constexpr (bit_type<_Tp>) {
return _Tp::_Bit_Len;
}
else {
static_assert(bit_type<_Up>, "Invalid common length");
return _Up::_Bit_Len;
}
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator + (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) + cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator+(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) + cast(rhs));
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator - (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) - cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator-(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) - cast(rhs));
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator * (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) * cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator*(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) * cast(rhs));
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator / (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) / cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator/(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) / cast(rhs));
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator & (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) & cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator&(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) & cast(rhs));
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator | (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) | cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator|(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) | cast(rhs));
}
template <typename _Tp, typename _Up>
requires bit_match <_Tp, _Up>
constexpr auto operator ^ (const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length <_Tp, _Up>();
return Bit <_Len> (cast(lhs) ^ cast(rhs));
template<typename _Tp, typename _Up>
requires bit_match<_Tp, _Up>
constexpr auto operator^(const _Tp &lhs, const _Up &rhs) {
constexpr auto _Len = get_common_length<_Tp, _Up>();
return Bit<_Len>(cast(lhs) ^ cast(rhs));
}
template <typename _Tp>
concept int_or_bit = int_type <_Tp> || bit_type <_Tp>;
template<typename _Tp>
concept int_or_bit = int_type<_Tp> || bit_type<_Tp>;
template <bit_type _Tp, int_or_bit _Up>
constexpr auto operator << (const _Tp &lhs, const _Up &rhs) {
return Bit <_Tp::_Bit_Len> (cast(lhs) << (cast(rhs) & kMaxLength));
template<bit_type _Tp, int_or_bit _Up>
constexpr auto operator<<(const _Tp &lhs, const _Up &rhs) {
return Bit<_Tp::_Bit_Len>(cast(lhs) << (cast(rhs) & kMaxLength));
}
template <bit_type _Tp, int_or_bit _Up>
constexpr auto operator >> (const _Tp &lhs, const _Up &rhs) {
return Bit <_Tp::_Bit_Len> (cast(lhs) >> (cast(rhs) & kMaxLength));
template<bit_type _Tp, int_or_bit _Up>
constexpr auto operator>>(const _Tp &lhs, const _Up &rhs) {
return Bit<_Tp::_Bit_Len>(cast(lhs) >> (cast(rhs) & kMaxLength));
}
template <bit_type _Tp>
constexpr auto operator ~ (const _Tp &value) {
return Bit <_Tp::_Bit_Len> (~cast(value));
template<bit_type _Tp>
constexpr auto operator~(const _Tp &value) {
return Bit<_Tp::_Bit_Len>(~cast(value));
}
template <bit_type _Tp>
constexpr auto operator ! (const _Tp &value) {
return ~value;
template<bit_type _Tp>
constexpr auto operator!(const _Tp &value) {
return ~value;
}
template <bit_type _Tp>
constexpr auto operator + (const _Tp &value) {
return Bit <_Tp::_Bit_Len> (+cast(value));
template<bit_type _Tp>
constexpr auto operator+(const _Tp &value) {
return Bit<_Tp::_Bit_Len>(+cast(value));
}
template <bit_type _Tp>
constexpr auto operator - (const _Tp &value) {
return Bit <_Tp::_Bit_Len> (-cast(value));
template<bit_type _Tp>
constexpr auto operator-(const _Tp &value) {
return Bit<_Tp::_Bit_Len>(-cast(value));
}
template <int_or_bit _Tp, int_or_bit _Up>
constexpr bool operator && (const _Tp &lhs, const _Up &rhs) {
return cast(lhs) && cast(rhs);
template<int_or_bit _Tp, int_or_bit _Up>
constexpr bool operator&&(const _Tp &lhs, const _Up &rhs) {
return cast(lhs) && cast(rhs);
}
template <int_or_bit _Tp, int_or_bit _Up>
constexpr bool operator || (const _Tp &lhs, const _Up &rhs) {
return cast(lhs) || cast(rhs);
template<int_or_bit _Tp, int_or_bit _Up>
constexpr bool operator||(const _Tp &lhs, const _Up &rhs) {
return cast(lhs) || cast(rhs);
}
template <int_or_bit _Tp, int_or_bit _Up>
constexpr bool operator == (const _Tp &lhs, const _Up &rhs) {
return cast(lhs) == cast(rhs);
template<int_or_bit _Tp, int_or_bit _Up>
constexpr bool operator==(const _Tp &lhs, const _Up &rhs) {
return cast(lhs) == cast(rhs);
}
template <int_or_bit _Tp, int_or_bit _Up>
constexpr auto operator <=> (const _Tp &lhs, const _Up &rhs) {
return cast(lhs) <=> cast(rhs);
template<int_or_bit _Tp, int_or_bit _Up>
constexpr auto operator<=>(const _Tp &lhs, const _Up &rhs) {
return cast(lhs) <=> cast(rhs);
}