Starting using murmur2 when combining multiple size_t's into a single hash, and also for basic_string. Also made hash<thread::id> ever so slighly more portable. I had to tweak one test which is questionable (definitely not portable) anyway.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2011-12-05 00:08:45 +00:00
parent cf2654bae7
commit 40c13d31c5
4 changed files with 101 additions and 18 deletions

View File

@@ -183,6 +183,9 @@ __thread_id get_id();
} // this_thread
class _LIBCPP_VISIBLE __thread_id;
template<> struct _LIBCPP_VISIBLE hash<__thread_id>;
class _LIBCPP_VISIBLE __thread_id
{
// FIXME: pthread_t is a pointer on Darwin but a long on Linux.
@@ -226,10 +229,9 @@ private:
friend __thread_id this_thread::get_id();
friend class _LIBCPP_VISIBLE thread;
friend struct _LIBCPP_VISIBLE hash<__thread_id>;
};
template<class _Tp> struct hash;
template<>
struct _LIBCPP_VISIBLE hash<__thread_id>
: public unary_function<__thread_id, size_t>
@@ -237,8 +239,7 @@ struct _LIBCPP_VISIBLE hash<__thread_id>
_LIBCPP_INLINE_VISIBILITY
size_t operator()(__thread_id __v) const
{
const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
return *__p;
return hash<pthread_t>()(__v.__id_);
}
};