[#absl-HashState]
= xref:absl.adoc[absl]::HashState
:relfileprefix: ../
:mrdocs:

A type&hyphen;erased version of the hash state concept&period;

== Synopsis

Declared in `&lt;absl&sol;hash&sol;hash&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class HashState
    : public hash&lowbar;internal::HashStateBase&lt;HashState&gt;
----

== Description

A type erased version of the hash state concept, for use in user&hyphen;defined `AbslHashValue` implementations that can&apos;t use templates (such as PImpl classes, virtual functions, etc&period;)&period; The type erasure adds overhead so it should be avoided unless necessary&period;

Note&colon; This wrapper will only erase calls to combine&lowbar;contiguous(H, const unsigned char&ast;, size&lowbar;t) RunCombineUnordered(H, CombinerF)

All other calls will be handled internally and will not invoke overloads provided by the wrapped class&period;

Users of this class should still define a template `AbslHashValue` function, but can use `absl&colon;&colon;HashState&colon;&colon;Create(&amp;state)` to erase the type of the hash state and dispatch to their private hashing logic&period;

This state can be used like any other hash state&period; In particular, you can call `HashState&colon;&colon;combine()` and `HashState&colon;&colon;combine&lowbar;contiguous()` on it&period;

Example&colon;

class Interface &lcub; public&colon; template &lt;typename H&gt; friend H AbslHashValue(H state, const Interface&amp; value) &lcub; state &equals; H&colon;&colon;combine(std&colon;&colon;move(state), std&colon;&colon;type&lowbar;index(typeid(&ast;this)))&semi; value&period;HashValue(absl&colon;&colon;HashState&colon;&colon;Create(&amp;state))&semi; return state&semi; &rcub; private&colon; virtual void HashValue(absl&colon;&colon;HashState state) const &equals; 0&semi; &rcub;&semi;

class Impl &colon; Interface &lcub; private&colon; void HashValue(absl&colon;&colon;HashState state) const override &lcub; absl&colon;&colon;HashState&colon;&colon;combine(std&colon;&colon;move(state), v1&lowbar;, v2&lowbar;)&semi; &rcub; int v1&lowbar;&semi; std&colon;&colon;string v2&lowbar;&semi; &rcub;&semi;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `hash&lowbar;internal::HashStateBase&lt;HashState&gt;`
| 
|===

== Type Aliases

[cols="1"]
|===
| Name
| xref:absl/HashState/AbslInternalPiecewiseCombiner.adoc[`AbslInternalPiecewiseCombiner`] 
| xref:absl/HashState/is_hashable.adoc[`is&lowbar;hashable`] 
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/HashState/2constructor-00.adoc[`HashState`]         [.small]#[constructor]#
| Constructors
| xref:absl/HashState/operator_assign-07.adoc[`operator&equals;`] 
| Assignment operators
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/HashState/Create.adoc[`Create`] 
| Create a new `HashState` instance that wraps `state`&period;
| xref:absl/HashState/combine-0e0.adoc[`combine`] 
| 
| xref:absl/HashState/combine_contiguous-0a.adoc[`combine&lowbar;contiguous`] 
| Combine a contiguous array of elements into a hash state&period;
| xref:absl/HashState/combine_unordered.adoc[`combine&lowbar;unordered`] 
| 
| xref:absl/HashState/combine_weakly_mixed_integer.adoc[`combine&lowbar;weakly&lowbar;mixed&lowbar;integer`] 
| Combine a weakly&hyphen;mixed integer into a hash state&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:absl/HashState/combine-0e5.adoc[`combine`] 
| Combine an arbitrary number of values into a hash state&period;
| xref:absl/HashState/combine_contiguous-0b.adoc[`combine&lowbar;contiguous`] 
| Combine a contiguous range of elements into a hash state&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `absl::hash&lowbar;internal::CombineRaw`
| 
| `absl::hash&lowbar;internal::HashStateBase`
| 
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
