Simplify type trait usage (remove ::value usage)

This commit is contained in:
Tim Wojtulewicz 2023-07-06 14:04:13 -07:00
parent cd7ebdb2ed
commit 4957dace64
3 changed files with 9 additions and 10 deletions

View file

@ -27,21 +27,20 @@ alignas(16) unsigned long long KeyedHash::shared_siphash_key[2];
// we use the following lines to not pull in the highwayhash headers in Hash.h - but to check the // we use the following lines to not pull in the highwayhash headers in Hash.h - but to check the
// types did not change underneath us. // types did not change underneath us.
static_assert(std::is_same<hash64_t, highwayhash::HHResult64>::value, static_assert(std::is_same_v<hash64_t, highwayhash::HHResult64>,
"Highwayhash return values must match hash_x_t"); "Highwayhash return values must match hash_x_t");
static_assert(std::is_same<hash128_t, highwayhash::HHResult128>::value, static_assert(std::is_same_v<hash128_t, highwayhash::HHResult128>,
"Highwayhash return values must match hash_x_t"); "Highwayhash return values must match hash_x_t");
static_assert(std::is_same<hash256_t, highwayhash::HHResult256>::value, static_assert(std::is_same_v<hash256_t, highwayhash::HHResult256>,
"Highwayhash return values must match hash_x_t"); "Highwayhash return values must match hash_x_t");
void KeyedHash::InitializeSeeds(const std::array<uint32_t, SEED_INIT_SIZE>& seed_data) void KeyedHash::InitializeSeeds(const std::array<uint32_t, SEED_INIT_SIZE>& seed_data)
{ {
static_assert(std::is_same<decltype(KeyedHash::shared_siphash_key),
highwayhash::SipHashState::Key>::value,
"Highwayhash Key is not unsigned long long[2]");
static_assert( static_assert(
std::is_same<decltype(KeyedHash::shared_highwayhash_key), highwayhash::HHKey>::value, std::is_same_v<decltype(KeyedHash::shared_siphash_key), highwayhash::SipHashState::Key>,
"Highwayhash HHKey is not uint64_t[4]"); "Highwayhash Key is not unsigned long long[2]");
static_assert(std::is_same_v<decltype(KeyedHash::shared_highwayhash_key), highwayhash::HHKey>,
"Highwayhash HHKey is not uint64_t[4]");
if ( seeds_initialized ) if ( seeds_initialized )
return; return;

View file

@ -108,7 +108,7 @@ UHF::UHF(Hasher::seed_t arg_seed)
// times. // times.
Hasher::digest UHF::hash(const void* x, size_t n) const Hasher::digest UHF::hash(const void* x, size_t n) const
{ {
static_assert(std::is_same<highwayhash::SipHashState::Key, decltype(seed.h)>::value, static_assert(std::is_same_v<highwayhash::SipHashState::Key, decltype(seed.h)>,
"Seed value is not the same type as highwayhash key"); "Seed value is not the same type as highwayhash key");
return highwayhash::SipHash(seed.h, reinterpret_cast<const char*>(x), n); return highwayhash::SipHash(seed.h, reinterpret_cast<const char*>(x), n);
} }

View file

@ -49,7 +49,7 @@ void BasicThread::SetName(const char* arg_name)
void BasicThread::SetOSName(const char* arg_name) void BasicThread::SetOSName(const char* arg_name)
{ {
// Do it only if libc++ supports pthread_t. // Do it only if libc++ supports pthread_t.
if constexpr ( std::is_same<std::thread::native_handle_type, pthread_t>::value ) if constexpr ( std::is_same_v<std::thread::native_handle_type, pthread_t> )
zeek::util::detail::set_thread_name(arg_name, zeek::util::detail::set_thread_name(arg_name,
reinterpret_cast<pthread_t>(thread.native_handle())); reinterpret_cast<pthread_t>(thread.native_handle()));
} }