refactor(bit): change some concept constraints
This commit is contained in:
@ -7,6 +7,14 @@ namespace dark {
|
||||
using max_size_t = std::uint32_t;
|
||||
using max_ssize_t = std::int32_t;
|
||||
|
||||
static constexpr std::size_t kMaxLength = std::numeric_limits<max_size_t>::digits;
|
||||
|
||||
template <std::size_t _Len>
|
||||
consteval max_size_t make_mask() {
|
||||
static_assert(_Len <= kMaxLength, "Mask length out of range");
|
||||
return _Len == kMaxLength ? ~max_size_t(0) : (max_size_t(1) << _Len) - 1;
|
||||
}
|
||||
|
||||
} // namespace dark
|
||||
|
||||
namespace dark::concepts {
|
||||
@ -38,4 +46,8 @@ concept bit_match =
|
||||
(bit_type <_Lhs> && bit_type <_Rhs> && _Lhs::_Bit_Len == _Rhs::_Bit_Len)
|
||||
|| (int_type <_Lhs> || int_type <_Rhs>);
|
||||
|
||||
template <typename _Tp, std::size_t _Len>
|
||||
concept bit_convertible =
|
||||
(bit_type <_Tp> && _Tp::_Bit_Len == _Len) || int_type <_Tp>;
|
||||
|
||||
} // namespace dark::concepts
|
||||
|
Reference in New Issue
Block a user