1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

Use if constexpr in hash_struct function

This commit is contained in:
scribam 2019-03-16 19:30:04 +01:00 committed by Ivan
parent 6c5ea068c9
commit 786dc6ef40

View File

@ -28,20 +28,19 @@ namespace rpcs3
template<typename T> template<typename T>
static size_t hash_struct(const T& value) static size_t hash_struct(const T& value)
{ {
// TODO: use c++17 if constexpr
static constexpr auto block_sz = sizeof(T); static constexpr auto block_sz = sizeof(T);
if ((block_sz & 0x7) == 0) if constexpr ((block_sz & 0x7) == 0)
{ {
return hash_struct_base<T, u64>(value); return hash_struct_base<T, u64>(value);
} }
if ((block_sz & 0x3) == 0) if constexpr ((block_sz & 0x3) == 0)
{ {
return hash_struct_base<T, u32>(value); return hash_struct_base<T, u32>(value);
} }
if ((block_sz & 0x1) == 0) if constexpr ((block_sz & 0x1) == 0)
{ {
return hash_struct_base<T, u16>(value); return hash_struct_base<T, u16>(value);
} }