#pragma once #include #include #include "types.h" // only works for 64 bit systems constexpr size_t _FNV_offset_basis = 14695981039346656037ULL; constexpr size_t _FNV_prime = 1099511628211ULL; inline size_t append_bytes(const unsigned char* _First) noexcept { size_t _Val = _FNV_offset_basis; for (; *_First; ++_First) { _Val ^= static_cast(*_First); _Val *= _FNV_prime; } return _Val; } inline size_t append_bytes(const astring_view& view) noexcept { return append_bytes(view.str); } template struct hasher { template typename std::enable_if< i == sizeof...(Types), size_t>::type hashi(const std::tuple& record) const { return 534235245539ULL; } template typename std::enable_if< i < sizeof ...(Types), size_t>::type hashi(const std::tuple& record) const { using current_type = typename std::decay>::type>::type; if constexpr (is_cstr()) return append_bytes((const unsigned char*)std::get(record)) ^ hashi(record); else return std::hash()(std::get(record)) ^ hashi(record); } size_t operator()(const std::tuple& record) const { return hashi(record); } };