

If it is arithmetic type then we will just try to cast it to unsigned int. If pthread_t is implemented as a pointer then we will calculate hash for the pointed object. If we need to compare two thread ids we just simply call pthread_equal(tid1, tid2) īut for operator ::calculate(tid1) ::calculate(tid2) If (char* data = reinterpret_cast(thread_id)) Static unsigned long calculate(T* thread_id) Static unsigned long calculate(T thread_id) I'm making template class with two partial specialization - one for pointers and one for arithmetic types template ::value> Suppose we have thred_id class wrapper, which should be less-then-comparable, equality-comparable and of course printable.

So I found solution which I would like to share and discuss it's portability. Pthread_equal function exists to compare two thread id's for equality, however it's not possible to compare them with operators = > (portable I mean of course) because on some of implementations pthread_t is a pointer to structure. What I actually need is portable compare and print for *nix pthread identifiers (pthread_t).
