hash: use std::hash for string hashing

This commit is contained in:
Justin Viiret 2017-08-10 16:58:48 +10:00 committed by Matthew Barr
parent 25170b32eb
commit fe31b387e8

View File

@ -35,6 +35,7 @@
#define UTIL_HASH_H #define UTIL_HASH_H
#include <functional> #include <functional>
#include <string>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
@ -123,9 +124,15 @@ struct ue2_hash<T, typename std::enable_if<has_hash_member<T>::value>::type> {
} }
}; };
/** \brief Hash for any container type that supports std::begin(). */ /**
* \brief Hash for any container type that supports std::begin().
*
* We exempt std::string as std::hash<std:string> is provided and quicker.
*/
template<typename T> template<typename T>
struct ue2_hash<T, typename std::enable_if<is_container<T>::value && struct ue2_hash<T, typename std::enable_if<
is_container<T>::value &&
!std::is_same<typename std::decay<T>::type, std::string>::value &&
!has_hash_member<T>::value>::type> { !has_hash_member<T>::value>::type> {
size_t operator()(const T &obj) const { size_t operator()(const T &obj) const {
size_t v = 0; size_t v = 0;