Skip to content

Commit

Permalink
Update get_integral_result.adoc
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Nov 15, 2024
1 parent 4e1f846 commit 66360a2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/hash2/reference/get_integral_result.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,27 @@ template<class T, class R> constexpr T get_integral_result( R const& r );
template<class T, class R> constexpr T get_integral_result( R const& r );
```

Requires: ::
`T` must be an integral type that is not `bool`.
`R` must be a valid _hash algorithm_ result type; that is, it must be an unsigned integer type, or an array-like type with a `value_type` of `unsigned char` (`std::array<unsigned char, N>` or `digest<N>`.)

Returns: ::
A value that is derived from `r` in a way that is as uniformly distributed over the possible values of `T` as possible. `r` is assumed to have been produced by a `result()` invocation of a _hash algorithm_.

Remarks: ::
When `R` is an array-like type, `get_integral_result` is allowed to assume that `r` has been produced by a high quality hash algorithm and that therefore its values are uniformly distributed over the entire domain of `R`.

Example: ::
+
```
template<class T, class Hash> struct my_hash
{
std::size_t operator()( std::string const& st ) const noexcept
{
Hash hash;
boost::hash2::hash_append( hash, {}, st );
return boost::hash2::get_integral_result<std::size_t>( hash.result() );
}
};
```

0 comments on commit 66360a2

Please sign in to comment.