proxygen
folly::detail::integral_hasher< I > Struct Template Reference

#include <Hash.h>

Public Types

using folly_is_avalanching = bool_constant<(sizeof(I) >=8||sizeof(size_t)==4)>
 

Public Member Functions

size_t operator() (I const &i) const noexcept
 

Detailed Description

template<typename I>
struct folly::detail::integral_hasher< I >

Definition at line 316 of file Hash.h.

Member Typedef Documentation

template<typename I>
using folly::detail::integral_hasher< I >::folly_is_avalanching = bool_constant<(sizeof(I) >= 8 || sizeof(size_t) == 4)>

Definition at line 318 of file Hash.h.

Member Function Documentation

template<typename I>
size_t folly::detail::integral_hasher< I >::operator() ( I const &  i) const
inlinenoexcept

Definition at line 320 of file Hash.h.

320  {
321  static_assert(sizeof(I) <= 16, "Input type is too wide");
322  /* constexpr */ if (sizeof(I) <= 4) {
323  auto const i32 = static_cast<int32_t>(i); // impl accident: sign-extends
324  auto const u32 = static_cast<uint32_t>(i32);
325  return static_cast<size_t>(hash::jenkins_rev_mix32(u32));
326  } else if (sizeof(I) <= 8) {
327  auto const u64 = static_cast<uint64_t>(i);
328  return static_cast<size_t>(hash::twang_mix64(u64));
329  } else {
330  auto const u = to_unsigned(i);
331  auto const hi = static_cast<uint64_t>(u >> sizeof(I) * 4);
332  auto const lo = static_cast<uint64_t>(u);
333  return hash::hash_128_to_64(hi, lo);
334  }
335  }
uint64_t hash_128_to_64(const uint64_t upper, const uint64_t lower) noexcept
Definition: Hash.h:570
uint32_t jenkins_rev_mix32(uint32_t key) noexcept
Definition: Hash.h:97
constexpr auto to_unsigned(T const &t) -> typename std::make_unsigned< T >::type
Definition: Utility.h:399
uint64_t twang_mix64(uint64_t key) noexcept
Definition: Hash.h:49

The documentation for this struct was generated from the following file: