Added docs for std::hash

But I do not know if they copile with QuickBook.
This commit is contained in:
Andrzej Krzemienski
2022-05-23 21:00:00 +02:00
parent 52abe4842e
commit ec677383dc
4 changed files with 50 additions and 2 deletions

View File

@ -2,7 +2,7 @@
[quickbook 1.4] [quickbook 1.4]
[authors [Cacciola Carballal, Fernando Luis]] [authors [Cacciola Carballal, Fernando Luis]]
[copyright 2003-2007 Fernando Luis Cacciola Carballal] [copyright 2003-2007 Fernando Luis Cacciola Carballal]
[copyright 2014-2021 Andrzej Krzemieński] [copyright 2014-2022 Andrzej Krzemieński]
[category miscellaneous] [category miscellaneous]
[id optional] [id optional]
[dirname optional] [dirname optional]

View File

@ -73,6 +73,16 @@
} // namespace boost } // namespace boost
namespace std {
template <typename T>
struct hash<boost::optional<T> > ; ``[link reference_std_hash_spec __GO_TO__]``
template <typename T>
struct hash<boost::optional<T&> > ; ``[link reference_std_hash_spec __GO_TO__]``
} // namespace std
[endsect] [endsect]

View File

@ -1408,3 +1408,37 @@ assert (addressof(*opt0) == addressof(y));
`` ``
[endsect] [endsect]
[section Detailed Semantics - std::hash Specializations]
__SPACE__
[#reference_std_hash_spec]
``
namespace std {
template <typename T>
struct hash<boost::optional<T> > ;
template <typename T>
struct hash<boost::optional<T&> > ;
} // namespace std
``
The specialization `hash<optional<T>>`` is enabled if and only if
`hash<remove_­const_­t<T>> is enabled. When enabled, for an object `o`
of type `optional<T>``, if `o.has_­value() == true`, then `hash<optional<T>>()(o)`
evaluates to the same value as `hash<remove_­const_­t<T>>()(*o)``; otherwise it
evaluates to an unspecified value.
The member functions are not guaranteed to be `noexcept`.
[caution
You may get compiler errors when your program provides specializations for
`std::hash<boost::optional<T>>`. If this happens, define macro
`BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH` to suppress the specializations
of `std::hash` in this library.
]
[endsect]

View File

@ -1,7 +1,7 @@
[/ [/
Boost.Optional Boost.Optional
Copyright (c) 2015 - 2021 Andrzej Krzemienski Copyright (c) 2015 - 2022 Andrzej Krzemienski
Distributed under the Boost Software License, Version 1.0. Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at (See accompanying file LICENSE_1_0.txt or copy at
@ -11,6 +11,10 @@
[section:relnotes Release Notes] [section:relnotes Release Notes]
[heading Boost Release 1.80]
* Added specializations for `std::hash<boost::opitonal<T>>`. This fixes [@https://github.com/boostorg/optional/issues/55 issue #55].
[heading Boost Release 1.79] [heading Boost Release 1.79]
* Fixed [@https://github.com/boostorg/optional/issues/98 issue #98]. * Fixed [@https://github.com/boostorg/optional/issues/98 issue #98].