diff --git a/src/base/stl_helpers/hash_helpers.hh b/src/base/stl_helpers/hash_helpers.hh index f638ea92f2..1432d522bd 100644 --- a/src/base/stl_helpers/hash_helpers.hh +++ b/src/base/stl_helpers/hash_helpers.hh @@ -40,6 +40,11 @@ #include "base/type_traits.hh" +#include +#include +#include +#include + namespace gem5::stl_helpers { @@ -165,6 +170,32 @@ using hash_impl::make_hash_for; using hash_impl::hash_value; using hash_impl::is_hash_enabled; +/* + * Provide unordered_map and unordered_set with stl_helpers::hash functions. + * These aliases enable clean use of stl_helpers::hash as default Hash template + * parameter. The reason for not using an alias is that template type aliases + * with default template arguments do not behave well with template parameter + * deductions in certain situations. One must remember that std::unordered_X + * is not a polymorphic type and as such, gem5::stl_helpers::unordered_X shall + * never be owned as a std::unordered_X. + */ +template< + typename Key, + typename T, + typename Hash = hash, + typename KeyEqual = std::equal_to, + typename Allocator = std::allocator< std::pair >> +struct unordered_map: std::unordered_map +{}; + +template< + typename Key, + typename Hash = hash, + typename KeyEqual = std::equal_to, + typename Allocator = std::allocator> +struct unordered_set: std::unordered_set +{}; + } // namespace gem5::stl_helpers #endif // BASE_STL_HELPERS_HASH_HELPERS_HH