diff --git a/include/frozen/bits/basic_types.h b/include/frozen/bits/basic_types.h index 6483072..2d77604 100644 --- a/include/frozen/bits/basic_types.h +++ b/include/frozen/bits/basic_types.h @@ -99,7 +99,7 @@ class carray { static constexpr void check_initializer(std::initializer_list init) { (void)init; - constexpr_assert(init.size() >= N, "Cannot initialize a carray with an smaller initializer list"); + constexpr_assert(init.size() == N, "Cannot initialize a carray with an initializer list of different size."); } public: diff --git a/include/frozen/bits/pmh.h b/include/frozen/bits/pmh.h index 1bb4021..4fb2bef 100644 --- a/include/frozen/bits/pmh.h +++ b/include/frozen/bits/pmh.h @@ -184,15 +184,23 @@ struct pmh_tables : private Hasher { }; // Make pmh tables for given items, hash function, prg, etc. -template +template pmh_tables constexpr make_pmh_tables(const carray & items, Hash const &hash, + KeyEqual const &equal, Key const &key, PRG prg) { // Step 1: Place all of the keys into buckets auto step_one = make_pmh_buckets(items, hash, key, prg); +#ifndef NDEBUG + // Step 1.5: Detect redundant keys. + for(auto const& bucket : step_one.buckets) + for(std::size_t i = 1; i < bucket.size(); ++i) + constexpr_assert(!equal(key(items[0]), key(items[i])), "unique keys"); +#endif + // Step 2: Sort the buckets to process the ones with the most items first. auto buckets = step_one.get_sorted_buckets(); diff --git a/include/frozen/unordered_map.h b/include/frozen/unordered_map.h index 7c0ffb3..2405385 100644 --- a/include/frozen/unordered_map.h +++ b/include/frozen/unordered_map.h @@ -83,7 +83,7 @@ class unordered_map : private KeyEqual { , items_{items} , tables_{ bits::make_pmh_tables( - items_, hash, bits::GetKey{}, default_prg_t{})} {} + items_, hash, equal, bits::GetKey{}, default_prg_t{})} {} explicit constexpr unordered_map(container_type items) : unordered_map{items, Hash{}, KeyEqual{}} { } diff --git a/include/frozen/unordered_set.h b/include/frozen/unordered_set.h index 0c53b15..482034b 100644 --- a/include/frozen/unordered_set.h +++ b/include/frozen/unordered_set.h @@ -77,7 +77,7 @@ class unordered_set : private KeyEqual { : KeyEqual{equal} , keys_{keys} , tables_{bits::make_pmh_tables( - keys_, hash, bits::Get{}, default_prg_t{})} {} + keys_, hash, equal, bits::Get{}, default_prg_t{})} {} explicit constexpr unordered_set(container_type keys) : unordered_set{keys, Hash{}, KeyEqual{}} {}