8#include <unordered_map>
22 kblib::is_linear_container_v<
24 string> and kblib::is_contiguous_v<std::string> and kblib::is_trivially_hashable_v<std::string::value_type> and kblib::is_trivially_hashable_v<int*>,
26static_assert(kblib::asserts::is_trivial_container<std::vector<char>>,
"");
29static_assert(kblib::is_trivially_hashable_v<no_padding>);
31 std::declval<no_padding&>())),
35 no_padding>> and std::is_invocable_r_v<std::size_t, kblib::FNV_hash<no_padding>,
const no_padding&>);
39static constexpr bool is_disabled_hash
43static constexpr bool is_enabled_hash
44 = std::is_nothrow_default_constructible_v<kblib::FNV_hash<T>>and
45 std::is_invocable_r_v<std::size_t, kblib::FNV_hash<T>,
const T&>;
61 std::unordered_map<std::tuple<std::wstring, int*>,
66 std::vector<std::basic_string<bool>>>;
67 static_assert(std::is_same<
decltype(test_map), map_t>::value,
"");
74 std::vector<std::basic_string<bool>>>>
78 KBLIB_UNUSED auto call = &
decltype(test_hash1)::operator();
85 static_assert(3452452_fnv64 == h_i(3452452ull),
86 "hash literal and FNH_hash don't agree");
92 static_assert(is_disabled_hash<std::vector<has_padding>>);
94 static_assert(is_disabled_hash<std::unordered_map<int, int>>);
100 (void)test_opt_hash(std::nullopt);
101 (void)test_opt_hash(42);
104 std::variant<int, int, std::string> var(std::in_place_index<1>, 42);
107 CHECK_FALSE(test_var_hash(var)
108 == test_var_hash(
decltype(var){std::in_place_index<0>, 42}));
119 (void)
kblib::FNV_hash<std::tuple<std::wstring, int*>, std::uint32_t>{}({});
121 (void)
kblib::FNV_hash<std::vector<int>::iterator, std::uint32_t>{}({});
122 (void)
kblib::FNV_hash<std::deque<char>::iterator, std::uint32_t>{}({});
134 std::vector<std::basic_string<bool>>>,
140 KBLIB_UNUSED auto call = &
decltype(test_hash1)::operator();
147 static_assert(3452452_fnv32 == h_i(3452452u),
148 "hash literal and FNH_hash don't agree");
162 (void)test_opt_hash(std::nullopt);
163 (void)test_opt_hash(42);
166 std::variant<int, int, std::string> var(std::in_place_index<1>, 42);
169 CHECK_FALSE(test_var_hash(var)
170 == test_var_hash(
decltype(var){std::in_place_index<0>, 42}));
Provides generic facilities for hashing data, and aliases for standard unordered containers using the...
constexpr bool is_invocable_v
std::unordered_map< Key, Value, FNV_hash<>, std::equal_to<> > hash_map
The primary template has to exist, but not be constructible, in order to be compatible with std::hash...
#define KBLIB_UNUSED
This internal macro is used to provide a fallback for [[maybe_unused]] in C++14.