Document that `AbslHashValue()` overloads are not allowed for pointer or other natively supported types. Explicitly note in `absl/hash/hash.h` that `AbslHashValue()` may only be defined for user-defined types that the author owns, and may not be defined for built-in pointer types (such as `const MyType*`), standard library types (such as `std::unique_ptr<MyType>`), or other types natively supported by `absl::Hash`. PiperOrigin-RevId: 1011638687
diff --git a/absl/hash/hash.h b/absl/hash/hash.h index 126c96f..28ab855 100644 --- a/absl/hash/hash.h +++ b/absl/hash/hash.h
@@ -254,6 +254,15 @@ // Note: unlike `std::hash', `absl::Hash` should never be specialized. It must // only be extended by adding `AbslHashValue()` overloads. // +// `AbslHashValue()` may only be defined for user-defined types (such as +// classes, structs, unions, or enums) that you own. It is not allowed to define +// `AbslHashValue()` overloads for built-in types such as pointers (e.g. +// `const MyType*`), standard library types (e.g. `std::unique_ptr<MyType>`), or +// types that `absl::Hash` natively supports. In `absl::Hash`, pointers are +// always hashed by their memory address; to hash pointers by their pointee +// value in a container, pass custom hash and equality functors to the container +// instead. +// template <typename T> using Hash = absl::hash_internal::Hash<T>;