mirror of
https://github.com/boostorg/container_hash.git
synced 2025-08-03 14:34:39 +02:00
Document support for nullptr and tuple-like types
This commit is contained in:
@@ -22,11 +22,13 @@ Out of the box, `boost::hash` supports
|
|||||||
|
|
||||||
* standard integral types (integers, character types, and `bool`);
|
* standard integral types (integers, character types, and `bool`);
|
||||||
* standard floating point types (`float`, `double`, `long double`);
|
* 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;
|
* enumeration types;
|
||||||
* C arrays;
|
* C arrays;
|
||||||
* `std::complex`;
|
* `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
|
* sequence-like types, both standard and user-defined (sequence-like types
|
||||||
have `begin()` and `end()` member functions returning iterators);
|
have `begin()` and `end()` member functions returning iterators);
|
||||||
* unordered sequences, standard or user-defined (sequences for which the hash
|
* unordered sequences, standard or user-defined (sequences for which the hash
|
||||||
|
@@ -8,6 +8,12 @@ https://www.boost.org/LICENSE_1_0.txt
|
|||||||
= Recent Changes
|
= Recent Changes
|
||||||
:idprefix: recent_
|
: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
|
== Boost 1.81.0
|
||||||
|
|
||||||
Major update.
|
Major update.
|
||||||
|
@@ -30,6 +30,7 @@ template<class T> struct is_range;
|
|||||||
template<class T> struct is_contiguous_range;
|
template<class T> struct is_contiguous_range;
|
||||||
template<class T> struct is_unordered_range;
|
template<class T> struct is_unordered_range;
|
||||||
template<class T> struct is_described_class;
|
template<class T> struct is_described_class;
|
||||||
|
template<class T> struct is_tuple_like;
|
||||||
|
|
||||||
} // namespace container_hash
|
} // namespace container_hash
|
||||||
|
|
||||||
@@ -89,8 +90,9 @@ template<class T>
|
|||||||
template<class A, class B>
|
template<class A, class B>
|
||||||
std::size_t hash_value( std::pair<A, B> const& v );
|
std::size_t hash_value( std::pair<A, B> const& v );
|
||||||
|
|
||||||
template<class... T>
|
// Enabled only when container_hash::is_tuple_like<T>::value is true
|
||||||
std::size_t hash_value( std::tuple<T...> const& v );
|
template<class T>
|
||||||
|
std::size_t hash_value( T const& v );
|
||||||
|
|
||||||
// Enabled only when container_hash::is_range<T>::value is true
|
// Enabled only when container_hash::is_range<T>::value is true
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -385,8 +387,9 @@ return seed;
|
|||||||
|
|
||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
template<class... T>
|
// Enabled only when container_hash::is_tuple_like<T>::value is true
|
||||||
std::size_t hash_value( std::tuple<T...> const& v );
|
template<class T>
|
||||||
|
std::size_t hash_value( T const& v );
|
||||||
----
|
----
|
||||||
|
|
||||||
Effects: ::
|
Effects: ::
|
||||||
@@ -395,15 +398,21 @@ Effects: ::
|
|||||||
----
|
----
|
||||||
std::size_t seed = 0;
|
std::size_t seed = 0;
|
||||||
|
|
||||||
boost::hash_combine( seed, std::get<0>(v) );
|
using std::get;
|
||||||
boost::hash_combine( seed, std::get<1>(v) );
|
|
||||||
|
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;
|
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]
|
[source]
|
||||||
----
|
----
|
||||||
@@ -703,3 +712,38 @@ template<class T> struct is_described_class
|
|||||||
|
|
||||||
Users are allowed to specialize `is_described_class` for their types
|
Users are allowed to specialize `is_described_class` for their types
|
||||||
if the default behavior does not deduce the correct value.
|
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.
|
||||||
|
Reference in New Issue
Block a user