Document support for nullptr and tuple-like types

This commit is contained in:
Peter Dimov
2022-11-29 02:00:06 +02:00
parent bf7a78594e
commit 2f4efbced4
3 changed files with 62 additions and 10 deletions

View File

@@ -22,11 +22,13 @@ Out of the box, `boost::hash` supports
* standard integral types (integers, character types, and `bool`);
* standard floating point types (`float`, `double`, `long double`);
* pointers (to objects and to functions, but not pointers to members);
* pointers (to objects and to functions, but not pointers to members)
and `nullptr`;
* enumeration types;
* C arrays;
* `std::complex`;
* `std::pair`, `std::tuple`;
* tuple-like types, such as `std::pair`, `std::tuple`, and user-defined
types that specialize `std::tuple_size` and provide `get<I>`;
* sequence-like types, both standard and user-defined (sequence-like types
have `begin()` and `end()` member functions returning iterators);
* unordered sequences, standard or user-defined (sequences for which the hash

View File

@@ -8,6 +8,12 @@ https://www.boost.org/LICENSE_1_0.txt
= Recent Changes
:idprefix: recent_
== Boost 1.82.0
* Added an overload of `hash_value` for `std::nullptr_t`.
* Added `is_tuple_like` and an overload of `hash_value` for
tuple-like types.
== Boost 1.81.0
Major update.

View File

@@ -30,6 +30,7 @@ template<class T> struct is_range;
template<class T> struct is_contiguous_range;
template<class T> struct is_unordered_range;
template<class T> struct is_described_class;
template<class T> struct is_tuple_like;
} // namespace container_hash
@@ -89,8 +90,9 @@ template<class T>
template<class A, class B>
std::size_t hash_value( std::pair<A, B> const& v );
template<class... T>
std::size_t hash_value( std::tuple<T...> const& v );
// Enabled only when container_hash::is_tuple_like<T>::value is true
template<class T>
std::size_t hash_value( T const& v );
// Enabled only when container_hash::is_range<T>::value is true
template<class T>
@@ -385,8 +387,9 @@ return seed;
[source]
----
template<class... T>
std::size_t hash_value( std::tuple<T...> const& v );
// Enabled only when container_hash::is_tuple_like<T>::value is true
template<class T>
std::size_t hash_value( T const& v );
----
Effects: ::
@@ -395,15 +398,21 @@ Effects: ::
----
std::size_t seed = 0;
boost::hash_combine( seed, std::get<0>(v) );
boost::hash_combine( seed, std::get<1>(v) );
using std::get;
boost::hash_combine( seed, get<0>(v) );
boost::hash_combine( seed, get<1>(v) );
// ...
boost::hash_combine( seed, std::get<N-1>(v) );
boost::hash_combine( seed, get<N-1>(v) );
return seed;
----
+
where `N` is `sizeof...(T)`.
where `N` is `std::tuple_size<T>::value`.
Remarks: ::
This overload is only enabled when
`container_hash::is_range<T>::value` is `false`.
[source]
----
@@ -703,3 +712,38 @@ template<class T> struct is_described_class
Users are allowed to specialize `is_described_class` for their types
if the default behavior does not deduce the correct value.
== <boost/container_hash/{zwsp}is_tuple_like.hpp>
Defines the trait `boost::container_hash::is_tuple_like`.
[source]
----
namespace boost
{
namespace container_hash
{
template<class T> struct is_tuple_like;
} // namespace container_hash
} // namespace boost
----
=== is_tuple_like<T>
[source]
----
template<class T> struct is_tuple_like
{
static constexpr bool value = /* see below */;
};
----
`is_tuple_like<T>::value` is `true` when `std::tuple_size<T>::value`
is valid.
Users are allowed to specialize `is_tuple_like` for their types
if the default behavior does not deduce the correct value.