diff --git a/doc/hash/intro.adoc b/doc/hash/intro.adoc index 2e7adf2..f54aa5d 100644 --- a/doc/hash/intro.adoc +++ b/doc/hash/intro.adoc @@ -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`; * 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 diff --git a/doc/hash/recent.adoc b/doc/hash/recent.adoc index 0ad37d1..ad10ad1 100644 --- a/doc/hash/recent.adoc +++ b/doc/hash/recent.adoc @@ -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. diff --git a/doc/hash/reference.adoc b/doc/hash/reference.adoc index 957dd69..4b81516 100644 --- a/doc/hash/reference.adoc +++ b/doc/hash/reference.adoc @@ -30,6 +30,7 @@ template struct is_range; template struct is_contiguous_range; template struct is_unordered_range; template struct is_described_class; +template struct is_tuple_like; } // namespace container_hash @@ -89,8 +90,9 @@ template template std::size_t hash_value( std::pair const& v ); -template - std::size_t hash_value( std::tuple const& v ); +// Enabled only when container_hash::is_tuple_like::value is true +template + std::size_t hash_value( T const& v ); // Enabled only when container_hash::is_range::value is true template @@ -385,8 +387,9 @@ return seed; [source] ---- -template - std::size_t hash_value( std::tuple const& v ); +// Enabled only when container_hash::is_tuple_like::value is true +template + 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(v) ); +boost::hash_combine( seed, get(v) ); return seed; ---- + -where `N` is `sizeof...(T)`. +where `N` is `std::tuple_size::value`. + +Remarks: :: +This overload is only enabled when +`container_hash::is_range::value` is `false`. [source] ---- @@ -703,3 +712,38 @@ template 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. + +== + +Defines the trait `boost::container_hash::is_tuple_like`. + +[source] +---- +namespace boost +{ + +namespace container_hash +{ + +template struct is_tuple_like; + +} // namespace container_hash + +} // namespace boost +---- + +=== is_tuple_like + +[source] +---- +template struct is_tuple_like +{ + static constexpr bool value = /* see below */; +}; +---- + +`is_tuple_like::value` is `true` when `std::tuple_size::value` +is valid. + +Users are allowed to specialize `is_tuple_like` for their types +if the default behavior does not deduce the correct value.