diff --git a/absl/hash/hash.h b/absl/hash/hash.h index aea7e1fb6c3..3658aa53c9f 100644 --- a/absl/hash/hash.h +++ b/absl/hash/hash.h @@ -80,11 +80,13 @@ #include #include +#include #include #include "absl/base/config.h" #include "absl/functional/function_ref.h" #include "absl/hash/internal/hash.h" +#include "absl/meta/type_traits.h" namespace absl { ABSL_NAMESPACE_BEGIN @@ -321,8 +323,12 @@ class HashState : public hash_internal::HashStateBase { // Create a new `HashState` instance that wraps `state`. All calls to // `combine()` and `combine_contiguous()` on the new instance will be // redirected to the original `state` object. The `state` object must outlive - // the `HashState` instance. - template + // the `HashState` instance. `T` must be a subclass of `HashStateBase` - + // users should not define their own HashState types. + template < + typename T, + absl::enable_if_t< + std::is_base_of, T>::value, int> = 0> static HashState Create(T* state) { HashState s; s.Init(state);