[ox/std] Add ResizedInt to get the same sign int with a different size
This commit is contained in:
parent
f24a0a4aab
commit
e583cade27
18
deps/ox/src/ox/std/types.hpp
vendored
18
deps/ox/src/ox/std/types.hpp
vendored
@ -128,6 +128,24 @@ using Signed = Int<sizeof(T) * 8>;
|
||||
template<typename T>
|
||||
using Unsigned = Uint<sizeof(T) * 8>;
|
||||
|
||||
// ResizedInt retains the sign while granting a new size
|
||||
template<typename T, std::size_t bits, bool si = T(-1) < T(0)>
|
||||
struct ResizedInt {
|
||||
};
|
||||
|
||||
template<typename T, std::size_t bits>
|
||||
struct ResizedInt<T, bits, true> {
|
||||
using type = typename SignedType<bits>::type;
|
||||
};
|
||||
|
||||
template<typename T, std::size_t bits>
|
||||
struct ResizedInt<T, bits, false> {
|
||||
using type = typename UnsignedType<bits>::type;
|
||||
};
|
||||
|
||||
template<typename T, std::size_t bits>
|
||||
using ResizedInt_t = typename ResizedInt<T, bits>::type;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user