#include #include template constexpr auto array_from_object(const T& obj) { std::array ret; for (std::size_t i = 0; i < sizeof(T); ++i) { ret[i] = reinterpret_cast(&obj)[i]; } return ret; } // iterator-aware hasher template < typename it, typename = std::enable_if_t< std::is_pointer())>::value // and // std::has_unique_object_representations())>::value >> constexpr auto FNV32a(it begin, it end) -> uint32_t { const uint32_t FNV_32_PRIME = 16777619; uint32_t hval = 2166136261; for (it p = begin; p != end; ++p) { // get *p as a reference to array of unsigned char auto repr = array_from_object(*p); for (auto ch : repr) { hval ^= std::uint32_t{ch}; hval *= FNV_32_PRIME; } } return hval; }