[libc++] Enable hash only for the correct types

Also implement LWG3705.
Fixes https://github.com/llvm/llvm-project/issues/55823

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D132338

GitOrigin-RevId: 98f6a56f5ea2fc4ae7f4283b97073667a9e32cde
5 files changed