#How to retrieve shift type for unsigned integer type?
1 messages · Page 1 of 1 (latest)
1 messages · Page 1 of 1 (latest)
For example for u64 shift type must be u6, for u32 must be u5 etc. How do I retrieve this type in a generic way? Is there any builtin function for that?
How to retrieve shift type for unsigned integer type?
Now I use this
fn shiftTypeOf(comptime T: type) type {
return switch(@sizeOf(T)) {
1 => u3,
2 => u4,
4 => u5,
8 => u6
};
}
Of course there should be some comptime checks if T is integer type dadada
i think there's a Log2Int helper in std.meta