From d38f64ded9ede265107cad85a18898ca881f8e0a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 6 Jun 2020 00:35:12 +0300 Subject: [PATCH] Update documentation --- doc/smart_ptr.adoc | 1 + doc/smart_ptr/changelog.adoc | 8 ++--- doc/smart_ptr/owner_hash.adoc | 56 +++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 doc/smart_ptr/owner_hash.adoc diff --git a/doc/smart_ptr.adoc b/doc/smart_ptr.adoc index 23dc5e5..8933811 100644 --- a/doc/smart_ptr.adoc +++ b/doc/smart_ptr.adoc @@ -37,6 +37,7 @@ include::smart_ptr/pointer_to_other.adoc[] include::smart_ptr/atomic_shared_ptr.adoc[] include::smart_ptr/owner_less.adoc[] include::smart_ptr/owner_equal_to.adoc[] +include::smart_ptr/owner_hash.adoc[] // appendix include::smart_ptr/techniques.adoc[] diff --git a/doc/smart_ptr/changelog.adoc b/doc/smart_ptr/changelog.adoc index 9de54f2..01b0f28 100644 --- a/doc/smart_ptr/changelog.adoc +++ b/doc/smart_ptr/changelog.adoc @@ -16,11 +16,11 @@ http://www.boost.org/LICENSE_1_0.txt ## Changes in 1.74.0 * Added `owner_equals` to `shared_ptr`, `weak_ptr`, `local_shared_ptr` -* Added `owner_equal_to` -* Added `std::hash` specializations for `shared_ptr`, `local_shared_ptr` * Added `owner_hash_value` to `shared_ptr`, `weak_ptr` -* Added `boost::hash` support and `std::hash`, `std::equal_to` - specializations for `weak_ptr` +* Added `owner_equal_to`, `owner_hash` +* Added `std::hash` specializations for `shared_ptr`, `local_shared_ptr` +* Added `boost::hash` support to, and `std::hash`, `std::equal_to` + specializations for, `weak_ptr` ## Changes in 1.72.0 diff --git a/doc/smart_ptr/owner_hash.adoc b/doc/smart_ptr/owner_hash.adoc new file mode 100644 index 0000000..b07ec00 --- /dev/null +++ b/doc/smart_ptr/owner_hash.adoc @@ -0,0 +1,56 @@ +//// +Copyright 2020 Peter Dimov +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#owner_hash] +# owner_hash +:toc: +:toc-title: +:idprefix: owner_hash_to_ + +## Description + +`owner_hash` is a helper function object that takes a smart pointer `p` +and returns `p.owner_hash_value()`. It's useful for creating unordered +containers of `shared_ptr` that use ownership-based equality, instead of +the default pointer value equality. (It can be used with `weak_ptr` too, +but there's no need, because `boost::hash` and `std::hash` for `weak_ptr` +already use ownership-based equality.) + +## Example + +``` +std::unordered_set< boost::shared_ptr, + boost::owner_hash< boost::shared_ptr >, + boost::owner_equal_to< boost::shared_ptr > > set; +``` + +## Synopsis + +`owner_hash` is defined in ``. + +``` +namespace boost { + + template struct owner_hash + { + typedef std::size_t result_type; + typedef T argument_type; + + std::size_t operator()( T const & p ) const noexcept; + }; +} +``` + +## Members + +``` +std::size_t operator()( T const & p ) const noexcept; +``` +[none] +* {blank} ++ +Returns:: + `p.owner_hash_value()`.